Skip to content

fix(a1): implement secure access control in the e-commerce API - #655

Closed
gabrielesequeira wants to merge 1 commit into
globocom:masterfrom
gabrielesequeira:fix/ecommerce-access-control
Closed

gabrielesequeira wants to merge 1 commit into
globocom:masterfrom
gabrielesequeira:fix/ecommerce-access-control

Conversation

@gabrielesequeira

@gabrielesequeira gabrielesequeira commented Oct 16, 2026 •

Copy link
Copy Markdown

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 UserID via 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:

  • Validate the session token and extract the authenticated username.
  • Retrieve the user associated with that session from the database.
  • Compare the user's UserID with the ID requested in the URL.
  • Return a 403 Forbidden response if the IDs do not match, while still allowing access to the user's own ticket.
  • Return the ticket if the UserID matches.

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:

  • When authenticated as user 1, I was able to access my own ticket.
  • When authenticated as user 1 and attempting to retrieve the ticket for user 2, I received an "access denied" response.

This confirmed that the application allowed authorized access to the user's own ticket while preventing access to another user's ticket.

@gabrielesequeira gabrielesequeira changed the title Fix access control in ecommerce API fix(a1): implement secure access control in the e-commerce API Oct 23, 2026
@vitor-mauricio

Copy link
Copy Markdown

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 🤔 ?

@vitor-mauricio vitor-mauricio added mitigation solution 🔒 This is a possible way to fix this vulnerability Vulnerable Ecommerce API labels Nov 11, 2026
@gabrielesequeira

Copy link
Copy Markdown
Author

It would be nice to test the solution you suggested @vitor-mauricio . Maybe we could take a look at this implementation together sometime?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

mitigation solution 🔒 This is a possible way to fix this vulnerability Vulnerable Ecommerce API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants