Closed Bug 1803811 Opened 3 years ago Closed 3 years ago

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)

defect

Tracking

()

RESOLVED FIXED

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:

  1. Is the User Story field enabled for the bug? (e.g. the component is not on the exclusion list)
  2. Is the caller's account nonzero and the User Story for the bug nonnull?
  3. 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)
  • Users:
    • Attacker (in the editbugs group)
    • Victim (admin, or otherwise in the insidergroup and editbugs groups of your instance)

(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

  1. 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.
  2. 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").
  3. As Attacker, browse to /show_bug.cgi?id=ID replacing ID with that of Victim's bug from Step 2 and observe the "Access Denied" error.
  4. Now browse to /show_bug.cgi?format=multiple&id=ID&id=ID replacing ID twice 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).

Flags: sec-bounty?

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!

Group: websites-security → bugzilla-security
Type: task → defect
Component: Other → General
Product: Websites → bugzilla.mozilla.org

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

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

Flags: needinfo?(dkl)
Assignee: nobody → dkl
Status: NEW → ASSIGNED
Flags: needinfo?(dkl)
Attached patch 1803911_1.patch — — Splinter Review

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.

Attachment #9306751 - Flags: review?(sheehan)

Comment on attachment 9306751 [details] [diff] [review]
1803911_1.patch

LGTM.

Attachment #9306751 - Flags: review?(sheehan) → review+

(In reply to Connor Sheehan [:sheehan] from comment #7)

Comment on attachment 9306751 [details] [diff] [review]
1803911_1.patch

LGTM.

Thanks Connor. This fix will go to production first thing tomorrow. Thanks for the report!

Thanks for the fast fix David! Tested the patch locally and LGTM here too.

Status: ASSIGNED → RESOLVED
Closed: 3 years ago
Resolution: --- → FIXED

This fix is live now.

Flags: sec-bounty? → sec-bounty+
Group: bugzilla-security
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: