OutOfMemoryError found by OSS-Fuzz (issue 60248)
- Dominant language
- Java
- Stars
- 3.6k
- Forks
- 1.4k
- Avg merge
- 2d 11h
- Merged PRs (30d)
- 88
Description
### Description
Dear Apache Lucene maintainers,
The OutOfMemory is triggered in this [line](https://github.com/apache/lucene/blob/main/lucene/core/src/java/org/apache/lucene/util/ArrayUtil.java#L400) by parse() function from QueryParser when a crafted untrusted input is processed by it.
We have reviewed the finding and it might be security-related due to the potential of a denial of service. We would appreciate it if you could take a look at the finding. Do you see a risk that this might be exploited by untrusted input?
Part of the stack trace:
== Java Exception: com.code_intelligence.jazzer.api.FuzzerSecurityIssueLow: Out of memory (use '-Xmx1710m' to reproduce)
Caused by: java.lang.OutOfMemoryError: Java heap space
at org.apache.lucene.util.ArrayUtil.growExact(ArrayUtil.java:400)
at org.apache.lucene.util.ArrayUtil.grow(ArrayUtil.java:412)
at org.apache.lucene.util.BytesRefBuilder.grow(BytesRefBuilder.java:60)
at org.apache.lucene.util.BytesRefBuilder.append(BytesRefBuilder.java:71)
at org.apache.lucene.util.BytesRefBuilder.append(BytesRefBuilder.java:78)
at org.apache.lucene.util.BytesRefBuilder.append(BytesRefBuilder.java:83)
at org.apache.lucene.util.BytesRefBuilder.copyBytes(BytesRefBuilder.java:115)
at org.apache.lucene.analysis.miscellaneous.ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl.copyTo(ConcatenateGraphFilter.java:380)
at org.apache.lucene.analysis.miscellaneous.ConcatenateGraphFilter$BytesRefBuilderTermAttributeImpl.clone(ConcatenateGraphFilter.java:386)
at org.apache.lucene.util.AttributeSource$State.clone(AttributeSource.java:52)
at org.apache.lucene.util.AttributeSource.captureState(AttributeSource.java:302)
at org.apache.lucene.analysis.CachingTokenFilter.fillCache(CachingTokenFilter.java:92)
at org.apache.lucene.analysis.CachingTokenFilter.incrementToken(CachingTokenFilter.java:70)
at org.apache.lucene.util.QueryBuilder.createFieldQuery(QueryBuilder.java:318)
at org.apache.lucene.util.QueryBuilder.createFieldQuery(QueryBuilder.java:257)
at org.apache.lucene.queryparser.classic.QueryParserBase.newFieldQuery(QueryParserBase.java:468)
at org.apache.lucene.queryparser.classic.QueryParserBase.getFieldQuery(QueryParserBase.java:457)
at org.apache.lucene.queryparser.classic.QueryParserBase.handleBareTokenQuery(QueryParserBase.java:824)
at org.apache.lucene.queryparser.classic.QueryParser.Term(QueryParser.java:494)
at org.apache.lucene.queryparser.classic.QueryParser.Clause(QueryParser.java:366)
at org.apache.lucene.queryparser.classic.QueryParser.Query(QueryParser.java:251)
at org.apache.lucene.queryparser.classic.QueryParser.TopLevelQuery(QueryParser.java:223)
at org.apache.lucene.queryparser.classic.QueryParserBase.parse(QueryParserBase.java:136)
...
We have added a reproducer zip which contains a README that describes how to reproduce the issue.
Reproducer Zip: https://drive.google.com/file/d/1wIbOOZcuEW1uOoTosAtJWxREVwt9imaw/view?usp=sharing
Fuzz target: https://github.com/google/oss-fuzz/blob/master/projects/lucene/QueryParserFuzzer.java
Note: We have updated the fuzz test in the zip file to simplify the debugging process.
OSS-Fuzz issue link: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=60248
Hint: The provided OSS-Fuzz Issue link is only accessible if the issue is fixed or you are the maintainer of the OSS-Fuzz project.
### Version and environment details
_No response_
Contributor guide
Research direction
Start with the reproducer README and the QueryParserFuzzer.java target, then trace the reported path through QueryParser.parse() to ArrayUtil.java line 400. Reproduce the OutOfMemoryError with the supplied input and determine whether the crafted query reliably causes the reported denial-of-service risk; the issue does not specify a concrete code change.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- search
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100