Any BMO user with editbugs can view the User Story for any private bug due to edge case in show-multiple.html.tmpl
Categories
(bugzilla.mozilla.org :: General, defect)
Tracking
()
People
(Reporter: 40826d, Assigned: dkl)
Details
(Keywords: reporter-external, sec-moderate, wsec-authorization, Whiteboard: [reporter-external] [web-bounty-form] [verif?])
Attachments
(3 files)
Summary
Users in the editbugs group can set the "User Story" field on bugs (and are generally trusted to edit most bug fields), but only on bugs that they have permission to read.
As editbugs users are not admins or part of an insidergroup, by default they will receive an error if they try to view a bug whose visibility is restricted ("private bug").
There however exists an edge case where the User Story for any private bug can be revealed when show_bug.cgi is loaded with the multiple format.
This is likely because in the show-multiple template, the sub-processing block for comments lives outside of the bug.error if-statement, causing it to be rendered even if the bug's error state is NotPermitted:
[% BLOCK bug_display %]
<h1>
# ...
</h1>
<table class="bugfields">
[% IF bug.error %]
# (if the bug is private and the attacker can't see it,
# the NotPermitted error is rendered and we stop here)
[% ELSE %]
# (if the bug is public or the attacker can see it,
# the bug fields are rendered here)
[% END %]
[% Hook.process("last_row", "bug/show-multiple.html.tmpl") %]
</table>
<br>
[% PROCESS bug/comments.html.tmpl
comments = bug.comments %]
# (regardless, the User Story for the bug is rendered here)
[% END %]
The sub-processing block for comments checks for privacy and prevents any comments on the private bug from being returned, but the User Story is a special field called by the comment_banner hook outside of the main processing block:
[% Hook.process("comment_banner") %]
The comment_banner hook returns early if any of the following checks fail, but since we are an editbugs user and the User Story does exist, all checks pass and the User Story is returned:
- Is the User Story field enabled for the bug? (e.g. the component is not on the exclusion list)
- Is the caller's account nonzero and the User Story for the bug nonnull?
- Can the caller set the User Story for the bug?
[% RETURN UNLESS bug.user_story_visible.0 %]
[% RETURN IF user.id == 0 && bug.cf_user_story == "" %]
[% can_edit_story = bug.check_can_change_field('cf_user_story', 0, 1).allowed %]
# (the code after this point fetches and renders the User Story for the bug)
Environment
- Bugzilla version:
- 20221202.1
- Confirmed on:
- Local Docker container (
bmo.test)
- Local Docker container (
- Users:
- Attacker (in the
editbugsgroup) - Victim (admin, or otherwise in the
insidergroupandeditbugsgroups of your instance)
- Attacker (in the
(I could not reproduce this issue on bugzilla-dev.allizom.org because, while I can create security-sensitive bugs on this instance, my test users are not in the editbugs group.)
Steps to Reproduce
- As Victim, create a new bug with the visibility restricted ("private bug"). You can do this by browsing to
/enter_bug.cgi?format=__default__, selecting a product, and then marking the "Security" checkboxes before you submit. - Browse to the newly created bug, select "Edit Bug", and set the "User Story" field to text of your choice (e.g. "this is a User Story on a private bug").
- As Attacker, browse to
/show_bug.cgi?id=IDreplacingIDwith that of Victim's bug from Step 2 and observe the "Access Denied" error. - Now browse to
/show_bug.cgi?format=multiple&id=ID&id=IDreplacingIDtwice with that of Victim's bug from Step 2 and observe that you can view the User Story despite not having access to the underlying bug.
Impact
Any user in the editbugs group can view the User Story associated with any private bug, which in production may reveal the existence and functionality of unreleased Mozilla products (which in turn may be confidential data).
| Reporter | ||
Comment 1•3 years ago
|
||
| Reporter | ||
Comment 2•3 years ago
|
||
| Reporter | ||
Comment 3•3 years ago
|
||
Hi Frida, David, and team, hope all is well. Please let me know if anything is unclear or if you require any additional info. Thanks!
Updated•3 years ago
|
Comment 4•3 years ago
|
||
Hello Viridian,
Thank you for your report.
I have tested on staging and I can confirm that a user with editbugs permissions is able to see the User Story field even if they don't have access to the bug.
For reference, an unprivileged user is not able to see the field, when trying https://bugzilla.allizom.org/show_bug.cgi?format=multiple&id=1526799&id=1526799, I get error undef error - Can't call method "classification" on unblessed reference.
Thanks,
Frida
Comment 5•3 years ago
|
||
Hello David,
Can you please take a look?
I am assigning this bug an initial risk level of sec-moderate based on the available information. It highly depends on the intended use case of User Story and whether this field is actually used for security bugs. Please let me know if you have another assessment of the impact.
Thanks,
Frida
Updated•3 years ago
|
| Assignee | ||
Updated•3 years ago
|
| Assignee | ||
Comment 6•3 years ago
|
||
This patch moves the comments inside the ELSE condition where the bug is visible and user is allowed to see it. Before it was outside the ELSE and would execute even if the user could not see the bug. The User Story field would be visible then to anyone with editbugs permissions. With comments.html.tmpl moved, the User Story field would only be visible to those can SEE the bug and also have editbugs.
Part two of this patch is the user story field should not be displayed as part of comments.html.tmpl if the multiple format is specified since it is already part of the bug fields table above and would be displayed twice.
Comment 7•3 years ago
|
||
Comment on attachment 9306751 [details] [diff] [review]
1803911_1.patch
LGTM.
| Assignee | ||
Comment 8•3 years ago
|
||
(In reply to Connor Sheehan [:sheehan] from comment #7)
Comment on attachment 9306751 [details] [diff] [review]
1803911_1.patchLGTM.
Thanks Connor. This fix will go to production first thing tomorrow. Thanks for the report!
| Reporter | ||
Comment 9•3 years ago
|
||
Thanks for the fast fix David! Tested the patch locally and LGTM here too.
| Assignee | ||
Comment 10•3 years ago
|
||
Merged. Will be in production soon.
https://github.com/mozilla-bteam/bmo/commit/8ee942582ead999a235269123988df9608a7a513
| Assignee | ||
Comment 11•3 years ago
|
||
This fix is live now.
Updated•3 years ago
|
Updated•3 years ago
|
| Assignee | ||
Updated•2 years ago
|
Description
•