-
-
Notifications
You must be signed in to change notification settings - Fork 797
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
Longest collision chain in symbol table now exceeds maximum -- suspect a DoS attack #191
Comments
There have been recent fixes in this area (and as you point out, problem is indeed real), so just to make sure, which version are you using? Specifically, #187 was part of 2.5.2. |
2.5.2
|
Hmmh. That is odd -- I can not reproduce this from 2.5 branch (pre-2.5.3). As a temporary work-around, you may want to disable |
@pauldraper Would it be possible to verify that you are actually using 2.5.2: it is possible (for example) that you have 2.5.2 dependency to If you are building with maven, |
Thanks for the It turns out I was depending on 2.5.1 of jackson-core. I updated it to 2.5.2, but the problem still occurs. pom.xml <project>
<modelVersion>4.0.0</modelVersion>
<groupId>com.github.pauldraper</groupId>
<artifactId>jackson-demo</artifactId>
<version>0</version>
<dependencies>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.5.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.5.2</version>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>exec-maven-plugin</artifactId>
<version>1.2.1</version>
<configuration>
<mainClass>Main</mainClass>
</configuration>
</plugin>
</plugins>
</build>
</project> This is the code I am using; perhaps increasing the number of keys may do it for you. src/main/java/Main.java import com.fasterxml.jackson.databind.*;
import java.io.IOException;
class Main {
public static void main(String[] args) throws IOException {
ObjectMapper mapper = new ObjectMapper();
StringBuilder sb = new StringBuilder();
sb.append("{");
for (int i = 0; i < 400; i++) {
if (i > 0) {
sb.append(",");
}
sb.append(String.format("\"\\u%04x\":%d", i, i));
}
sb.append("}");
mapper.readTree(sb.toString());
System.out.println("SUCCESS!");
}
} |
One sort of related bug I found: |
On plus side, yes, that code does trigger the problem. Mystery deepens... :) |
Come to to think of it, my example was not strictly identical, since my escaping differed -- while decoded names are the same, escapes are different. |
Very interesting little bug. And quite specific: only occurs with character-based sources (not byte-), and only affects escaped characters. If so, escaped characters hash code was basically taken as that of backslash; and the specific tested case of a single escaped character meant all escaped Strings hashed into same value. So in a way, hash overflow detection correctly determined something was fishy. :-) I'll be checking in the fix, as well as test to catch the specific problem, shortly. |
Thanks! (FYI, the real-world use case was font data, where each character is a key, and the characters were escaped Unicode.) |
Makes sense -- I figured there was a real use case. But something that is not super common, since this was not a regression but just something that was uncovered due to lowered threshold for collision detedction. I assume it was lucky coincidence earlier that limit was 256.... :) |
Yeah. FYI, we actually ran into this a long time ago (when the threshold was much, much higher than 256). We've been building Jackson ourselves, with the limitation removed. It happened only in production, and I didn't figure out a reproducible case until today. |
Jackson fails to parse the simple JSON below
It fails with an exception.
According to the documentation,
TestWithTonsaSymbols must not try very hard :)
The text was updated successfully, but these errors were encountered: