Skip to content
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

textAccumulator.addText(buf, start, end) introduces security issue. #85

Open
ChangXiaoning opened this issue Sep 7, 2023 · 0 comments

Comments

@ChangXiaoning
Copy link

Reproduce code

import com.fasterxml.aalto.util.*;

public static void main (String[] args) {
   textAccumulator = new TextAccumulator();
   char[] buf = new char[1840165617];
   textAccumulator.addText(buf, 0, buf.length);
}

Output

Exception in thread "main" java.lang.OutOfMemoryError: Java heap space
	at java.lang.AbstractStringBuilder.<init>(AbstractStringBuilder.java:68)
	at java.lang.StringBuilder.<init>(StringBuilder.java:106)
	at com.fasterxml.aalto.util.TextAccumulator.addText(TextAccumulator.java:51)
	at TextAccumulatorTest.main(TextAccumulatorTest.java:31)

Environment

jdk 1.8
aalto-xml 1.3.2

Analysis

Our service invokes textAccumulator.addText(buf, start, end). However, if the user provides malicious start and end, making the variable len very large. When the program allocates heap for this.mBuilder, an OutOfMemoryError happens and our service crashes. textAccumulator.addText() should check user input start and end.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant