Skip to content

LUCENE-10101: Use getField() instead of getDeclaredField() to minimize security impact by analysis SPI discovery#298

Merged
uschindler merged 2 commits into
apache:mainfrom
uschindler:jira/LUCENE-10101
Sep 14, 2021
Merged

LUCENE-10101: Use getField() instead of getDeclaredField() to minimize security impact by analysis SPI discovery#298
uschindler merged 2 commits into
apache:mainfrom
uschindler:jira/LUCENE-10101

Conversation

@uschindler
Copy link
Copy Markdown
Contributor

@uschindler uschindler commented Sep 14, 2021

Before creating a pull request, please file an issue in the ASF Jira system for Lucene:

Description

This PR changes the AnalyisSPILoader's method to lookup the NAME field of the SPI to use Class#getField() instead of Class#getDeclaredField(). This does not require special security privileges if the class is in a related classloader. As getField() unfortunately also looks into superclass if the field is not found, the checks for validness of the field have to be changed to check the declaring class. In contrast, the public check is obsolete, as only public fields are returned.

Tests

Testing is hard, as our security policy of tests allows to do declared member access. So no test will be added. Testing will be done by Elasticsearch people (@romseygeek).

Checklist

Please review the following and check all that apply:

  • I have reviewed the guidelines for How to Contribute and my code conforms to the standards described there to the best of my ability.
  • I have created a Jira issue and added the issue ID to my pull request title.
  • I have given Lucene maintainers access to contribute to my PR branch. (optional but recommended)
  • I have developed this patch against the main branch.
  • I have run ./gradlew check.
  • I have added tests for my changes.

@uschindler uschindler self-assigned this Sep 14, 2021
Copy link
Copy Markdown
Contributor

@romseygeek romseygeek left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thanks @uschindler! cc @rjernst

@uschindler uschindler merged commit 3802bdc into apache:main Sep 14, 2021
@uschindler uschindler deleted the jira/LUCENE-10101 branch September 14, 2021 08:31
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

Successfully merging this pull request may close these issues.

2 participants