Skip to content

Fix URL signing api for URLs containing special characters - #12435

Open
ErykKul wants to merge 24 commits into
developfrom
fix-url-signing-special-characters
Open

Fix URL signing api for URLs containing special characters#12435
ErykKul wants to merge 24 commits into
developfrom
fix-url-signing-special-characters

Conversation

@ErykKul

@ErykKul ErykKul commented Jun 4, 2026

Copy link
Copy Markdown
Collaborator

What this PR does / why we need it:
Bug fix; URL signing for URLs containing special characters broken in 6.10, this PR fixes the introduced bug.

Which issue(s) this PR closes:
Issue not created, bug fixed directly here.

Special notes for your reviewer:
Added tests to prevent regression. Also, API requires now the signing secret to be set, otherwise it will not work.

Suggestions on how to test this:
No special testing needed, the unit tests should be sufficient.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:
No

Is there a release notes update needed for this change?:
Yes, included.

Additional documentation:
No

@ErykKul ErykKul added Size: 3 A percentage of a sprint. 2.1 hours. Type: Bug - Blocker Bug is blocking user work, no workaround available labels Jun 4, 2026
@ErykKul ErykKul added this to the 6.11 milestone Jun 4, 2026
@ErykKul ErykKul moved this to Ready for Review ⏩ in IQSS Dataverse Project Jun 4, 2026
@coveralls

coveralls commented Jun 4, 2026

Copy link
Copy Markdown

Coverage Status

Coverage is 25.047%fix-url-signing-special-characters into develop. No base build found for develop.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@ErykKul ErykKul moved this from Ready for Review ⏩ to In Progress 💻 in IQSS Dataverse Project Jun 4, 2026
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown

Test Results

404 tests   389 ✅  37m 2s ⏱️
 55 suites   15 💤
 55 files      0 ❌

Results for commit 3fb4cc1.

♻️ This comment has been updated with latest results.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

Comment thread doc/sphinx-guides/source/installation/config.rst
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@pdurbin pdurbin removed this from the 6.11 milestone Jun 8, 2026
@pdurbin

pdurbin commented Jul 17, 2026

Copy link
Copy Markdown
Member

@ErykKul I'm putting this on hold for now since I heard you're on vacation until Aug 4. Please resolve merge conflicts when you get back. Thanks!

…ecial-characters

# Conflicts:
#	src/main/java/edu/harvard/iq/dataverse/api/Access.java
@ErykKul

ErykKul commented Jul 18, 2026

Copy link
Copy Markdown
Collaborator Author

@pdurbin, I did the merge. This one was easy. If there is something bigger, then I will pick it up after Aug 4.

@github-actions

This comment has been minimized.

@pdurbin pdurbin moved this from On Hold ⌛ to Ready for QA ⏩ in IQSS Dataverse Project Jul 20, 2026
@cmbz cmbz added the FY27 Sprint 3 FY27 Sprint 3 (2026-07-29 - 2026-08-12) label Jul 29, 2026
@qqmyers qqmyers moved this from Ready for QA ⏩ to QA ✅ in IQSS Dataverse Project Aug 12, 2026
@qqmyers qqmyers self-assigned this Aug 12, 2026
@cmbz cmbz added the FY27 Sprint 4 FY27 Sprint 4 (2026-08-12 - 2026-08-26) label Aug 12, 2026
// behavior): validation reconstructs the signing string from the URL-decoded request, so
// re-encoding here (e.g. percent-encoding ':' and '/' in DOIs) would change the signed bytes
// and the signature would no longer match.
baseUrl = stripReservedParameters(baseUrl);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks for working with the existing code. FWIW: I think it would be cleaner overall for this general utility to not try fixing a caller's mistakes - perhaps it should throw an exception if one of the four params needed by the algorithm are sent (and never touch the url on the good path and thus not needing to strip anything). Similarly flagging/removing signed and key here because the caller doesn't strip them seems backwards.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

This wasn't introduced in this PR. It came in with the 6.10 guestbook changes (#12001), where the ?signed=true flow signs the incoming request URI, which can carry key=<apitoken> and signed=true. But agreed it's worth picking up here: I'll make signUrl throw if any of the four algorithm params are present and never touch the URL otherwise, and move the (byte-exact) stripping helper out of signUrl to the callers that build URLs from incoming requests.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done in 2e0749f: signUrl now throws an IllegalArgumentException if the base URL already contains one of the four signing params and never touches the URL otherwise. The byte-exact stripping helper moved out of signUrl to the ?signed=true flow in Access (the caller that actually receives those params in the request URI), and /api/admin/requestSignedUrl now returns a 400 naming the offending parameter instead of silently rewriting the supplied URL. Release note, docs and tests updated accordingly.

@qqmyers

qqmyers commented Aug 13, 2026

Copy link
Copy Markdown
Member

@ErykKul - are you around to be able to fix the minor merge conflict? (If not, I can fix it and go forward with QA/merge). Also - do I understand correctly there is no visible effect in 6.10 - the URLs it creates internally don't have characters that are affected by the bug, so the only thing to QA is regression testing and trying the create signed url api with something like a doi (with : and / ).

@github-actions

This comment has been minimized.

@ErykKul

ErykKul commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

The conflict should be gone already, I merged develop this morning before pushing (GitHub shows the branch as mergeable now).

And yes, that's my understanding too: the URLs Dataverse creates internally only contain numeric ids, so the only visible breakage in 6.10 is for requestSignedUrl with special characters in the url, like a doi (that's how rdm-integration ran into it). Besides that and regression testing, two things from this PR worth a quick try in QA: requestSignedUrl now returns 400 when the url already contains a reserved param, and the signing endpoints now error without dataverse.api.signing-secret instead of falling back to a weak key.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
56.5% Coverage on New Code (required ≥ 80%)

See analysis details on SonarQube Cloud

@ErykKul

ErykKul commented Aug 14, 2026

Copy link
Copy Markdown
Collaborator Author

@qqmyers Heads up before QA: a few more commits landed since my comments above. While testing against a real client I also made validation verbatim-first — the signature is checked against the raw request URI first, with the URL-decoded check kept as fallback — so a URL signed exactly as it will be used now works as received, and everything that validated before still validates. A final review pass added a couple of fixes on top: crafted user=!... values get a proper 401 instead of a 500, and tool-manifest urlTemplates get reserved params stripped before signing again like 6.10 did (otherwise key={apiToken} in a template would sign the user's real API token into the URL). All with unit tests; docs and release note updated. That's everything from my side.

@github-actions

Copy link
Copy Markdown

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:fix-url-signing-special-characters
ghcr.io/gdcc/configbaker:fix-url-signing-special-characters

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

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

Labels

FY26 Sprint 25 FY26 Sprint 25 (2026-06-03 - 2026-06-17) FY26 Sprint 26 FY26 Sprint 26 (2026-06-17 - 2026-07-01) FY27 Sprint 1 FY27 Sprint 1 (2026-07-01 - 2026-07-15) FY27 Sprint 2 FY27 Sprint 2 (2026-07-15 - 2026-07-29) FY27 Sprint 3 FY27 Sprint 3 (2026-07-29 - 2026-08-12) FY27 Sprint 4 FY27 Sprint 4 (2026-08-12 - 2026-08-26) Size: 3 A percentage of a sprint. 2.1 hours. Status: Merge Conflicts Merge conflicts must be resolved. Type: Bug - Blocker Bug is blocking user work, no workaround available

Projects

Status: QA ✅

Development

Successfully merging this pull request may close these issues.

6 participants