Repository navigation
fix(a1): implement secure access control in the e-commerce API - #655
Closed
gabrielesequeira wants to merge 1 commit into
Closed
gabrielesequeira wants to merge 1 commit into
gabrielesequeira wants to merge 1 commit into
Conversation
|
Nice @gabrielesequeira , I could not perform the attack after your solution 🐼. I like your approach to solving this problem: checking the JWT signature and verifying that the user actually possesses the ticket. As a point of interest for future issues, could we perhaps use a stronger, more secure signing secret to provide an even higher level of security 🤔 ? |
Author
|
It would be nice to test the solution you suggested @vitor-mauricio . Maybe we could take a look at this implementation together sometime? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This solution refers to which of the apps?
A1 - Broken Access Control - Vulnerable Ecommerce API
What did you do to mitigate the vulnerability?
Fixed an access control flaw in the Ecommerce API's ticket retrieval endpoint.
I noticied that the application received a
UserIDvia the URL, looked up that user in the database, and returned the ticket without verifying whether the authenticated user in the current session was the owner of that ID. Consequently, a user could modify the requested ID to access another person's ticket.To mitigate this vulnerability, I refactored
func GetTicket()to:UserIDwith the ID requested in the URL.403 Forbiddenresponse if the IDs do not match, while still allowing access to the user's own ticket.UserIDmatches.These changes ensure that users can only retrieve their own tickets, preventing unauthorized access to other users' tickets by manipulating the ID in the URL.
Did you test your changes? What commands did you run?
Yes. I created two users and tested the ticket retrieval process to verify that the access control validation worked correctly.
The tests confirmed that:
This confirmed that the application allowed authorized access to the user's own ticket while preventing access to another user's ticket.