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

Escape pipe character for injected users #5175

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

shikharj05
Copy link
Contributor

@shikharj05 shikharj05 commented Mar 17, 2025

Description

Escape pipe while setting UserInfo in ThreadContext

Common-utils PR- opensearch-project/common-utils#801

  • Category (Enhancement, New feature, Bug fix, Test fix, Refactoring, Maintenance, Documentation)
    Bug fix
  • Why these changes are required?
    Allow OIDC use-cases where username contain pipes.
  • What is the old behavior before changes and new behavior after changes?
    usernames, roles & tenants will escape pipe character if present.

Issues Resolved

#2756

Is this a backport? If so, please add backport PR # and/or commits #, and remove backport-failed label from the original PR.

Do these changes introduce new permission(s) to be displayed in the static dropdown on the front-end? If so, please open a draft PR in the security dashboards plugin and link the draft PR here

Testing

[Please provide details of testing done: unit testing, integration testing and manual testing]

Check List

  • [] New functionality includes testing
  • [NA] New functionality has been documented
  • [NA] New Roles/Permissions have a corresponding security dashboards plugin PR
  • [NA] API changes companion pull request created
  • Commits are signed per the DCO using --signoff

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

Signed-off-by: shikharj05 <[email protected]>
Copy link

codecov bot commented Mar 17, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 71.64%. Comparing base (00204dd) to head (abf23c7).
Report is 3 commits behind head on main.

Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #5175      +/-   ##
==========================================
- Coverage   71.68%   71.64%   -0.04%     
==========================================
  Files         337      337              
  Lines       22785    22788       +3     
  Branches     3605     3605              
==========================================
- Hits        16333    16327       -6     
- Misses       4651     4655       +4     
- Partials     1801     1806       +5     
Files with missing lines Coverage Δ
...earch/security/privileges/PrivilegesEvaluator.java 73.96% <100.00%> (ø)
...org/opensearch/security/support/SecurityUtils.java 68.51% <100.00%> (+1.85%) ⬆️

... and 8 files with indirect coverage changes

🚀 New features to boost your workflow:
  • Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@nibix
Copy link
Collaborator

nibix commented Mar 17, 2025

Do we know where the error message noted in #2756 comes from?

java.lang.IllegalStateException: Username cannot have '|' in the security plugin.

I do not see it touched in the PR, so I would guess that the error still persists.

@shikharj05
Copy link
Contributor Author

java.lang.IllegalStateException: Username cannot have '|' in the security plugin.

This error is specifically from AOS. The actual issue reported mentions usage of usage of Cognito with Amazon OpenSearch Service (AOS).

@cwperks
Copy link
Member

cwperks commented Mar 17, 2025

Thank you for the PR @shikharj05! The user's reporting the issue have only mentioned a problem with usernames in certain SSO providers. Do you think we should limit this change to username and add logic to forbid it in other fields like roles and backend roles or should we do a blanket escape for all fields?

@shikharj05
Copy link
Contributor Author

Thank you for the PR @shikharj05! The user's reporting the issue have only mentioned a problem with usernames in certain SSO providers. Do you think we should limit this change to username and add logic to forbid it in other fields like roles and backend roles or should we do a blanket escape for all fields?

IMO, it's better to escape all fields like roles, tenants, etc to be consistent and prevent future issues in the same area.

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.

3 participants