Repository navigation
Conversation
…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.
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. |
There was a problem hiding this comment.
🟡 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-actionrules 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
| 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 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

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.