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

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

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.

…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.
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
return undef if !defined $url || ref $url;
return undef
unless $url
=~ m{\Ahttp://(?:127\.0\.0\.1|localhost|\[::1\]):[1-9][0-9]{0,4}(?:/[A-Za-z0-9._~/-]*)?\z};
Comment thread enter_bug.cgi
Comment on lines +245 to +247
# A local tool that opened this form can ask to be told the new bug's ID.
my $callback = loopback_callback_url(scalar $cgi->param('creation_callback'));
$vars->{'creation_callback'} = $callback if $callback;
Comment on lines +111 to +113
[% IF creation_callback %]
<input type="hidden" name="creation_callback" value="[% creation_callback FILTER html %]">
[% END %]

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.

2 participants