Username validation for special characters#2277
Username validation for special characters#2277peternied merged 4 commits intoopensearch-project:mainfrom
Conversation
39b2627 to
d895275
Compare
|
Thank you for the change. Can you add tests as well? |
d895275 to
ba09e9d
Compare
|
Added unit tests. |
ba09e9d to
3d5f259
Compare
|
@rutuja-amazon Should I add any backport labels to this PR? |
3d5f259 to
c7f7ee1
Compare
|
|
||
| // username has special characters | ||
| response = rh.executePutRequest(ENDPOINT + "/internalusers/n@ag:ilum", "{\"hash\": \"123\"}", new Header[0]); | ||
| Assert.assertEquals(HttpStatus.SC_METHOD_NOT_ALLOWED, response.getStatusCode()); |
There was a problem hiding this comment.
Is this test case specifically related to this fix? If yes, why isn't it also HttpStatus.SC_BAD_REQUEST.
There was a problem hiding this comment.
Yes, we need to updated all test cases that use special characters in username to now fail at creation
There was a problem hiding this comment.
Agreed. Then shouldn't this PUT request with special characters in username get HttpStatus.SC_BAD_REQUEST, which would be consistent with the fix?
There was a problem hiding this comment.
Sounds good, updated to HttpStatus.SC_BAD_REQUEST.
c7f7ee1 to
d207161
Compare
| return; | ||
| } | ||
|
|
||
| Pattern usernamePattern = Pattern.compile("[$&+,:;=\\\\?@#|/'<>.^*()%!-]"); |
There was a problem hiding this comment.
I think . should be allowed
There was a problem hiding this comment.
Permitted .. Do we also allow @ in username?
There was a problem hiding this comment.
@ shouldn't be allowed and only one . should be allowed. Thoughts? @cwperks @peternied @davidlago
There was a problem hiding this comment.
Do we also allow -, _ and @ along with .? Please suggest.
In the current fix I have permitted the four special characters above.
a7d4d64 to
ad27f3e
Compare
Codecov Report
@@ Coverage Diff @@
## main #2277 +/- ##
============================================
+ Coverage 61.05% 61.07% +0.01%
Complexity 3270 3270
============================================
Files 259 260 +1
Lines 18337 18369 +32
Branches 3248 3251 +3
============================================
+ Hits 11196 11219 +23
- Misses 5555 5563 +8
- Partials 1586 1587 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
peternied
left a comment
There was a problem hiding this comment.
This change impacts forward combability as username might have been viable in older versions of OpenSearch that will no longer work.
| return; | ||
| } | ||
|
|
||
| Pattern usernamePattern = Pattern.compile("[$&+,:;=\\\\?@#|/'<>^*()%!-]"); |
There was a problem hiding this comment.
Username should not include special characters
Why not, are there bugs associated with these characters?
There was a problem hiding this comment.
permitting special characters results in security risk & vulnerabilities.
There was a problem hiding this comment.
Thanks for looking out for issues of this nature, could you be more specific as to the risks associated with individual characters? I am reticent to limit these usernames without cause.
If there is an issue please follow our reporting process [1] also quoted below.
Reporting a Vulnerability
If you discover a potential security issue in this project we ask that you notify AWS/Amazon Security via our vulnerability reporting page or directly via email to aws-security@amazon.com. Please do not create a public GitHub issue.
[1] https://github.com/opensearch-project/security/security/policy
There was a problem hiding this comment.
Added more details on the main thread #2277 (comment)
Signed-off-by: Rutuja Surve <rutuja@amazon.com>
ad27f3e to
2958f40
Compare
|
Requesting addition of backport labels @cwperks |
|
@rutuja-amazon which branches would you like this change to be backported to? |
|
@rutuja-amazon Since this is change is based on a LOW security finding we should discuss everything in the public on this pull request. Pulling in the context from our internal threads:
For the moment, lets block only the colon character. |
Signed-off-by: Peter Nied <petern@amazon.com>
|
@rutuja-amazon I've created rutuja-amazon#1, if you merge that pull request into this change we can get this issue fixed, what do you think? |
Issue is with other special characters as well, as discussed offline |
|
I've created an issue to track the set of special characters that should be included or not, and at this time the only exclusion that seems justified is colon |
|
Updated PR to only allow |
cwperks
left a comment
There was a problem hiding this comment.
The changes look good to me, once the code hygiene check is fixed I will approve this PR.
I'll take care of this to help get this merged more quickly... |
Signed-off-by: Peter Nied <petern@amazon.com>
|
Note; |
|
Failing CI check is known fixed in main, merging! |
|
The backport to To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.x 1.x
# Navigate to the new working tree
cd .worktrees/backport-1.x
# Create a new branch
git switch --create backport/backport-2277-to-1.x
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 efbc48b405ff6ff372c4821aa15c53fc50a409a3
# Push it to GitHub
git push --set-upstream origin backport/backport-2277-to-1.x
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.xThen, create a pull request where the |
|
The backport to To backport manually, run these commands in your terminal: # Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-1.3 1.3
# Navigate to the new working tree
cd .worktrees/backport-1.3
# Create a new branch
git switch --create backport/backport-2277-to-1.3
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 efbc48b405ff6ff372c4821aa15c53fc50a409a3
# Push it to GitHub
git push --set-upstream origin backport/backport-2277-to-1.3
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-1.3Then, create a pull request where the |
* Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b)
* Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b)
* Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b)
* Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b)
* Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b) Co-authored-by: rutuja-amazon <110013621+rutuja-amazon@users.noreply.github.com>
* Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b) Co-authored-by: rutuja-amazon <110013621+rutuja-amazon@users.noreply.github.com>
) * Username validation for special characters (#2277) * Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b)
) * Username validation for special characters (#2277) * Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b) * Fix compliation issue Signed-off-by: Peter Nied <petern@amazon.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: rutuja-amazon <110013621+rutuja-amazon@users.noreply.github.com>
…pensearch-project#2317) * Only prevent user creation on colon characters, separate out tests Signed-off-by: Rutuja Surve <rutuja@amazon.com> Signed-off-by: Rutuja Surve <110013621+rutuja-amazon@users.noreply.github.com> Signed-off-by: Peter Nied <petern@amazon.com> Co-authored-by: Peter Nied <petern@amazon.com> (cherry picked from commit efbc48b) Co-authored-by: rutuja-amazon <110013621+rutuja-amazon@users.noreply.github.com>
Add username validation: