Skip to content

Bug 2099955 - Add a creation_callback param to enter_bug.cgi that redirects to a loopback URL with the new bug ID - #2851

Open
ahal wants to merge 1 commit into
mozilla:masterfrom
ahal:ahal/mzywylstwlkr
Open

ahal wants to merge 1 commit into
mozilla:masterfrom
ahal:ahal/mzywylstwlkr

Conversation

@ahal

@ahal ahal commented Dec 1, 2026

Copy link
Copy Markdown
Member

A local tool, such as a coding agent, that opens a prefilled enter_bug.cgi form in the user's browser can pass creation_callback=http://127.0.0.1:PORT/path. After the bug is filed, post_bug.cgi redirects the browser there with ?bug_id=N instead of to show_bug.cgi, so the tool learns which bug was filed.

Only http URLs on 127.0.0.1, localhost or [::1] with an explicit port and a plain path are accepted, so this is not an open redirect. The loopback origins are added to the CSP form-action list, which browsers apply to the redirect after a form POST.

Copilot AI balanced review requested due to automatic review settings December 1, 2026 15:19
@ahal

ahal commented Dec 1, 2026

Copy link
Copy Markdown
Member Author

I'm leaving this in draft because it likely warrants a discussion and security review. It's just easier to request a feature with a patch attached these days ;)

But if this turns out to have security implications or if there's a better way to implement. We might want to close it.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Callback propagation is incomplete across guided, legacy, and product-selection flows, and validation still accepts invalid ports above 65535.

3 open issues
What changed in this PR

Adds a creation_callback parameter so local tools can receive the new bug ID after a user submits a prefilled bug-entry form.

Changes:

  • Adds loopback URL validation and unit tests.
  • Carries the callback through the modal creation form and redirects after filing.
  • Extends CSP form-action rules to allow loopback destinations.
File Description
t/​loopback-callback-url.t Tests accepted and rejected callback URLs.
post_bug.cgi Redirects to a validated callback with the new bug ID.
extensions/​BugModal/​template/​en/​default/​bug_modal/​create.html.tmpl Includes the callback as a hidden form field.
enter_bug.cgi Validates and exposes the callback to the template.
Bugzilla/​Util.pm Adds and exports the loopback URL validator.
Bugzilla/​Constants.pm Allows loopback destinations in CSP form-action rules.

Review effort: Balanced

Comment thread Bugzilla/Util.pm Resolved
Comment thread enter_bug.cgi Resolved
Comment thread Bugzilla/Constants.pm Resolved
@ahal
ahal force-pushed the ahal/mzywylstwlkr branch from 6df1ae8 to f54047e Compare December 3, 2026 15:49
@ahal

ahal commented Dec 3, 2026

Copy link
Copy Markdown
Member Author

Thanks, resolved the comments. Also went with handling the callback via JS rather than templates, so it would work across all the various bug submission forms.

Since you didn't outright say no, I guess this feature is something you'd consider taking? I guess I'll flag it ready for review.. though as you've guessed I'm not very familiar with the code base, so my personal confidence is low.

@ahal
ahal marked this pull request as ready for review December 3, 2026 15:53
…irects to a loopback URL with the new bug ID

A local tool, such as a coding agent, that opens a prefilled enter_bug.cgi
form in the user's browser can pass creation_callback=http://127.0.0.1:PORT/path.
After the bug is filed, post_bug.cgi redirects the browser there with
?bug_id=N instead of to show_bug.cgi, so the tool learns which bug was filed.

Only http URLs on 127.0.0.1, localhost or [::1] with an explicit port and a
plain path are accepted, so this is not an open redirect. The loopback
origins are added to the CSP form-action list, which browsers apply to the
redirect after a form POST.
@ahal
ahal force-pushed the ahal/mzywylstwlkr branch from f54047e to f94a493 Compare December 3, 2026 16:50
@dklawren

dklawren commented Dec 3, 2026

Copy link
Copy Markdown
Collaborator

Since you didn't outright say no, I guess this feature is something you'd consider taking? I guess I'll flag it ready for review.. though as you've guessed I'm not very familiar with the code base, so my personal confidence is low.

Yes I am willing to take it as a feature as it is relatively safe to do as long as it is localhost only. I will take a look at the new changes.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The “Find product” autocomplete drops creation_callback when navigating, so filing a bug after selecting a result redirects to show_bug.cgi and prevents the local tool from receiving the bug ID.

1 open issue
3 resolved since last review

Review effort: Balanced

Comment on lines +286 to +290
static addCreationCallback(params) {
const callback = document.querySelector('meta[name="creation-callback"]')?.content;

if (callback) {
params.set('creation_callback', callback);

@dklawren dklawren left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Plus the copilot suggested change.

[%- IF cloned_bug_id %]&cloned_bug_id=[% cloned_bug_id FILTER uri %][% END -%]
[%- IF format %]&format=[% format FILTER uri %][% END %]">
[%- IF format %]&format=[% format FILTER uri %][% END -%]
[%- IF creation_callback %]&creation_callback=[% creation_callback FILTER uri %][% END %]">

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

BMO overrides this template with extensions/BMO/template/en/default/global/choose-product.html.tmpl (product links, easyproduct block, prodcompsearch form), so this change never renders and creation_callback is dropped when an editbugs user picks a product; the override needs the same param

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants