Skip to content

fix(http/raw): persist QueryAuthStrategy params in ApplyAuthStrategy - #7410

Merged
Mzack9999 merged 2 commits into
projectdiscovery:devfrom
akhilesharora:fix/raw-query-auth-strategy
May 19, 2026
Merged

Mzack9999 merged 2 commits into
projectdiscovery:devfrom
akhilesharora:fix/raw-query-auth-strategy

Conversation

@akhilesharora

@akhilesharora akhilesharora commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

Proposed changes

Closes #7409

Request.ApplyAuthStrategy in pkg/protocols/http/raw/raw.go parses r.FullURL into a local parsed, appends the QueryAuthStrategy params to parsed.Params, then returns without writing the result back. Every other branch of the switch (CookiesAuthStrategy, HeadersAuthStrategy, BearerTokenAuthStrategy, BasicAuthStrategy) mutates r.Headers. The standalone QueryAuthStrategy.Apply and ApplyOnRR in pkg/authprovider/authx/query_auth.go both write back to req.URL.RawQuery. Only the raw-request path was missing the write-back, so raw templates that match a query auth secret silently drop the params and the request goes out unauthenticated.

Adding r.FullURL = parsed.String() after the params loop fixes it. New unit test in raw_test.go fails on dev and passes with the fix.

$ go test -v -run TestApplyAuthStrategy_QueryAuth_PersistsParams ./pkg/protocols/http/raw/...
=== RUN   TestApplyAuthStrategy_QueryAuth_PersistsParams
--- PASS: TestApplyAuthStrategy_QueryAuth_PersistsParams (0.00s)
PASS
ok  	github.com/projectdiscovery/nuclei/v3/pkg/protocols/http/raw	0.058s

Checklist

  • Pull request is created against the dev branch
  • All checks passed (lint, unit/integration/regression tests etc.) with my changes
  • I have added tests that prove my fix is effective or that my feature works
  • I have added necessary documentation (if appropriate)

Summary by CodeRabbit

  • Bug Fixes

    • Fixed an issue where authentication query parameters were not being persisted to the full request URL, ensuring credentials in auth strategies are correctly included in outgoing HTTP requests.
  • Tests

    • Added coverage to validate query param persistence and preservation, no-op behavior for absent strategies, handling of invalid URLs, and auth behaviors for cookies, headers, bearer tokens, and basic auth.

Review Change Stack

The QueryAuthStrategy case in raw.Request.ApplyAuthStrategy parses
r.FullURL into a local 'parsed', appends auth params to parsed.Params,
then returns without writing back to r.FullURL. Every other branch in
the same switch mutates r.Headers, and the standalone QueryAuthStrategy
.Apply / .ApplyOnRR in pkg/authprovider/authx/query_auth.go both write
back to req.URL.RawQuery. Only the raw-request branch was missing the
write-back, so raw templates matching a 'query' auth secret silently
drop the auth params.

Adds r.FullURL = parsed.String() after the loop. New unit test fails
on dev and passes with the fix.
@auto-assign
auto-assign Bot requested a review from Mzack9999 May 17, 2026 11:20
@coderabbitai

coderabbitai Bot commented May 17, 2026 •

Copy link
Copy Markdown
Contributor

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: deafea04-f900-4e37-b240-63f97352bb8a

📥 Commits

Reviewing files that changed from the base of the PR and between 33066e8 and d68a5ea.

📒 Files selected for processing (1)
  • pkg/protocols/http/raw/raw_test.go

Walkthrough

ApplyAuthStrategy's QueryAuthStrategy branch now writes the updated URL (with appended query auth params) back into Request.FullURL. A set of unit tests was added to verify query param persistence, preservation of existing params, invalid-URL behavior, nil-strategy no-op, cookies, headers, bearer token, and basic auth handling.

Changes

Query Auth Parameter Persistence + Tests

Layer / File(s) Summary
Persist query params in ApplyAuthStrategy
pkg/protocols/http/raw/raw.go
Assigns parsed.String() back to r.FullURL after adding query auth params in the QueryAuthStrategy branch.
ApplyAuthStrategy unit tests
pkg/protocols/http/raw/raw_test.go
Adds tests: TestApplyAuthStrategy_QueryAuth_PersistsParams, ..._PreservesExistingParams, ..._InvalidURLLeavesFullURLUnchanged, ..._NilStrategyIsNoOp, ..._CookiesAuth, ..._HeadersAuth, ..._BearerTokenAuth, ..._BasicAuth validating query, cookie, header, bearer, and basic auth behaviors.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 A little bug hid a query's ink,
I nudged one line — no more to sink.
Tests hop in rows, checking each part,
Cookies, headers, tokens, and base64 heart.
A tiny fix, now whole and smart.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and specifically describes the main change: fixing the QueryAuthStrategy to persist modified query parameters in r.FullURL within the ApplyAuthStrategy method.
Linked Issues check ✅ Passed The pull request fully addresses issue #7409 by adding r.FullURL = parsed.String() after appending query params in ApplyAuthStrategy and includes comprehensive unit tests validating query param persistence.
Out of Scope Changes check ✅ Passed All changes are directly within scope: the one-line fix in raw.go addresses the missing write-back, and the test file additions comprehensively validate the fix and related auth strategy behaviors without extraneous modifications.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@Mzack9999
Mzack9999 merged commit ca0c237 into projectdiscovery:dev May 19, 2026
33 of 34 checks passed
@akhilesharora
akhilesharora deleted the fix/raw-query-auth-strategy branch May 19, 2026 14:31
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
nuclei 3.9.0

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## What's Changed

### 🎉 New Features
* Added support for protocol redirects by @Mzack9999 in projectdiscovery/nuclei#7296
* Added impacket integration by @Mzack9999 in projectdiscovery/nuclei#7356
* Added wmi, tsch, scmr, and dcom helper modules for JS by @dwisiswant0 in projectdiscovery/nuclei#7388
* Added mirroring of -config, -report-config, and -dashboard flags for SDK callers by @ShubhamRasal in projectdiscovery/nuclei#7393


### 🐞 Bug Fixes
* Fixed DNS variables resolving issue by @Mzack9999 in projectdiscovery/nuclei#7379
* Fixed expressions to prefer exact placeholders over expressions by @dwisiswant0 in projectdiscovery/nuclei#7397
* Fixed an issue in JS where runtimes that outlive the interrupt grace period are not abandoned, by @Mzack9999 in projectdiscovery/nuclei#7378
* Fixed an issue in reporting/jira where status-not was not matched against the transition target status name by @knakul853 in projectdiscovery/nuclei#7361
* Fixed runner to write unsigned-templates warning (WRN) to stderr by @ChrisJr404 in projectdiscovery/nuclei#7371
* Fixed `InternalEvent` access serialization in interactsh by @dwisiswant0 in projectdiscovery/nuclei#7322
* Fixed workflow to ensure context is properly propagated to child and race steps by @dwisiswant0 in projectdiscovery/nuclei#7383
* Fixed reporting/gitlab by bumping client-go to v1.9.1 and widening IDs to int64 by @ShubhamRasal in projectdiscovery/nuclei#7398
* Fixed memogen to skip context correctly and auto-push scope to upstream by @Mzack9999 in projectdiscovery/nuclei#7419
* Fixed a slice-bounds panic in telnetmini's ParseNTLMResponse when handling truncated NTLM challenges by @tejgokani in projectdiscovery/nuclei#7425
* Fixed SMBv1 probing in JS to occur after SMB2 negotiation by @dwisiswant0 in projectdiscovery/nuclei#7430
* Fixed templates to reject unknown fields when loading JSON templates by @tejgokani in projectdiscovery/nuclei#7453
* Fixed persistence of QueryAuthStrategy parameters in ApplyAuthStrategy by @akhilesharora in projectdiscovery/nuclei#7410
* Fixed loader to warn when templates are excluded by `.nuclei-ignore` tags by @dogancanbakir in projectdiscovery/nuclei#7452

### Other Changes
* Splitted exact matches and pattern handling in catalog for improved performance by @mikhail5555 in projectdiscovery/nuclei#7340
* Updated README_PT-BR.md to reflect current project description and features by @gugacyber in projectdiscovery/nuclei#7405
* Fixed broken cloud scanning link by @dogancanbakir in projectdiscovery/nuclei#7413
* Bumped pdsec modules + govaluate/aurora migration by @dogancanbakir in projectdiscovery/nuclei#7414
* Dropped vulnerable docker/docker dependency by @dogancanbakir in projectdiscovery/nuclei#7447
* Used path-aware filesystem containment checks by @dwisiswant0 in projectdiscovery/nuclei#7420
* Centralized runtime session handling by @dwisiswant0 in projectdiscovery/nuclei#7449


## New Contributors
* @ChrisJr404 made their first contribution in projectdiscovery/nuclei#7371
* @gugacyber made their first contribution in projectdiscovery/nuclei#7405
* @akhilesharora made their first contribution in projectdiscovery/nuclei#7410
* @tejgokani made their first contribution in projectdiscovery/nuclei#7425

**Full Changelog**: https://github.com/projectdiscovery/nuclei/compare/v3.8.0...v3.9.0</pre>
  <p>View the full release notes at <a href="https://github.com/projectdiscovery/nuclei/releases/tag/v3.9.0">https://github.com/projectdiscovery/nuclei/releases/tag/v3.9.0</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!11229
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.

Raw HTTP templates silently drop query auth params (ApplyAuthStrategy)

2 participants