Repository navigation
Conversation
|
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
6df1ae8 to
f54047e
Compare
|
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. |
…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.
f54047e to
f94a493
Compare
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. |
There was a problem hiding this comment.
🟡 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
| static addCreationCallback(params) { | ||
| const callback = document.querySelector('meta[name="creation-callback"]')?.content; | ||
|
|
||
| if (callback) { | ||
| params.set('creation_callback', callback); |
dklawren
left a comment
There was a problem hiding this comment.
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 %]"> |
There was a problem hiding this comment.
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

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.