-
Notifications
You must be signed in to change notification settings - Fork 45
Add checking to avoid unexpected ArrayIndexOutOfBoundException #3395
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Signed-off-by: Arthur Chan <[email protected]>
The powsybl-core/ieee-cdf/ieee-cdf-model/src/main/java/com/powsybl/ieeecdf/model/IeeeCdfReader.java Lines 34 to 36 in 455fd74
The problem arises from the behavior of the Univocity
From the above understanding, this crash can be triggered easily by supplying an empty file or one with an invalid first line (malformed fixed-width format that doesn't match the expected bean schema for |
This is a stability issue due to a lack of validation for failed parsing and blindly assumed that the imported data is structured correctly. Here is a simple proof of concept to trigger the problem. import com.powsybl.ieeecdf.model.IeeeCdfReader;
import java.io.BufferedReader;
import java.io.StringReader;
public class ProofOfConcept {
public static void main(String[] args) throws Exception {
BufferedReader reader = new BufferedReader(new StringReader(""));
new IeeeCdfReader().read(reader);
}
} To execute and test the PoC, follow the steps below. It is assumed that OpenJDK 17.0.2 and Maven 3.9.9 is used.
You will get the following exception stack trace.
|
The root cause is down at the |
Signed-off-by: Arthur Chan <[email protected]>
Signed-off-by: Arthur Chan <[email protected]>
This is a proposed fix to stability issue discovered by OSS-Fuzz when fuzzing the powsybl-core module. The original OSS-Fuzz issue can be found in https://issues.oss-fuzz.com/u/1/issues/406332771.