342 Commits

Author SHA1 Message Date
Dwi Siswanto 20cbf0bd73 refactor: use path-aware filesystem containment checks (#7420)
* feat(filepath): add IsPathWithinAnyDirectory func

Signed-off-by: Dwi Siswanto <git@dw1.io>

* refactor: use path-aware filesystem containment checks

Several filesystem trust boundaries relied on
lexical prefix checks to decide whether a path
fell under an allowed directory. That let sibling
paths be treated as if they were children of
trusted directories.

Replace those checks with canonical path
containment checks for helper payload loading,
template archive extraction, custom template
metadata, template path classification, and
headless screenshot output validation.

Signed-off-by: Dwi Siswanto <git@dw1.io>

* adding more tests

* fixing tests

* adding test

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>
Co-authored-by: Mzack9999 <mzack9999@protonmail.com>
2026-06-04 21:03:51 +05:30
Dogan Can Bakir 9330f0186d Merge pull request #7414 from projectdiscovery/chore/deps-bump-and-govaluate-switch
chore(deps): bump pdsec modules + govaluate/aurora migration
2026-05-19 21:18:09 +03:00
Mzack9999 d68a5ea5b2 extending tests 2026-05-18 23:53:33 +02:00
Doğan Can Bakır 1ec64a3f95 chore(deps): bump pdsec modules; switch to projectdiscovery/govaluate and aurora v4
Bumps clistats, fastdialer, retryablehttp-go, dsl, networkpolicy,
ratelimit, sarif, utils, wappalyzergo, cdncheck. dsl v0.8.18 moves to
the projectdiscovery/govaluate fork, and utils v0.11.0 pulls aurora v4,
so the corresponding imports and type references are migrated.

Refs #7380.
2026-05-18 17:14:29 +03:00
Akhilesh Arora 33066e8ebc fix(http/raw): persist QueryAuthStrategy params in ApplyAuthStrategy
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.
2026-05-17 13:13:02 +02:00
Dwi Siswanto b4a9e0a75a fix(expressions): prefer exact placeholders over exprs
`FindExpressions` checks marker contents with
govaluate before doing normal placeholder
replacement. That breaks valid hyphenated names
like `request-id`: govaluate reads them as
subtraction lol, and the lookup fails with a
missing request parameter.

If a marker exactly matches a key in the
replacement map, treat it as a plain placeholder
and let normal replacement handle it. Authored
expressions should still be evaluated, and
malformed helper calls should still return errors.

Fixes #7395

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-05-12 04:45:58 +07:00
Dwi Siswanto 4f3e77f790 test(expressions): add TestEvaluateHyphenatedPlaceholderNames
Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-05-12 04:45:41 +07:00
Mzack9999 ed7cec560e adding protocols redirect (#7296) 2026-05-10 17:01:23 +07:00
Mzack9999 397ffaaf41 Merge pull request #7383 from projectdiscovery/dwisiswant0/fix/workflow/propagate-context-to-child-race-steps
fix(workflow): propagate context to child & race steps
2026-05-08 21:06:29 +02:00
Mzack9999 89d0e65c1d Merge pull request #7322 from projectdiscovery/dwisiswant0/fix/interactsh/serialize-InternalEvent-access
fix(interactsh): serialize `InternalEvent` access
2026-05-07 22:10:57 +02:00
Dwi Siswanto 805bcfe76f fix(workflow): propagate context to child & race steps
Workflow inputs get updated with extracted values,
but later executors don't refresh their template
contexts from that state. Child subtemplates reuse
the same input object, letting sibling state leak
across concurrent executions. HTTP race requests
also ignore dynamic values when building requests.

Fix this by syncing the current workflow input
into each executor's template context, cloning
inputs passed to subtemplates, and forwarding
dynamic values to race request generation.

Fixes #5399

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-05-08 02:59:49 +07:00
Doğan Can Bakır 10831d6188 fix lint 2026-05-06 12:28:15 +03:00
Mzack9999 637036ecb2 fixing dns vars 2026-05-05 00:05:43 +02:00
Mikhail Epifanov ad74c601c4 fix(js): interrupt goja runtime on context cancel (#7343)
* Interrupt goja runtime on context cancel

* undo import formats

* do both actions in same go-routine to prevent any possible race condition

* Convert the watchdog, into a simpeler construction which still guarantees the same promises

* move the recover to the go routine, and return named return since we now can use the channel

* remove unnecessary tests

* add extra safety in case process refuses to get interrupted

* remove unnecessary ExecFuncWithTwoReturns

* remove named return values
2026-04-16 15:17:55 +07:00
Doğan Can Bakır c5c2127d28 fix flaky TestActionWaitDialog on Windows CI 2026-04-15 16:14:28 +08:00
Doğan Can Bakır 73d2afc327 merge dev and resolve testutils import conflict 2026-04-15 15:37:18 +08:00
Doğan Can Bakır d305dd6f86 add cross-platform service name fallback and port dedup 2026-04-15 15:28:04 +08:00
Dogan Can Bakir 0383fbfcb8 Merge pull request #7325 from projectdiscovery/fix/headless-tlsi-addheader
Fix headless JS loading with -tlsi and addheader/setheader
2026-04-15 09:23:25 +03:00
Dwi Siswanto f893b6c0cb refactor: native tests (#7307)
Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-04-15 05:27:07 +07:00
Dwi Siswanto 6c803c74d1 fix(expressions): avoid helper eval in literal checks (#7321)
* fix(expressions): avoid helper eval in literal checks

`hasLiteralsOnly()` currently evaluates helper
expressions while deciding whether "{{...}}"
contains unresolved variables, which makes
validation paths run side-effectful helpers.

Just replace that runtime eval with a
`Vars()` len check so unresolved-variable
detection literally stays literal (am I writing it
right?), and of course side-effect free.

Also make `Evaluate()` return template-authored
expression compile/eval errors instead of
logging and then keep continuing, so malformed
helper calls still fail in the rendering path.

Fixes #7320

Signed-off-by: Dwi Siswanto <git@dw1.io>

* fix(javascript): avoid nil map panic on arg eval failure

`getArgsCopy()` logs and counts argument
evaluation failures, but continues to store Port
in `argsCopy` even when `evaluateArgs()` returns.
This causes malformed JavaScript args like
"{{base64()}}" to panic instead of returning the
original error.

Return the evaluation error immediately after
reporting it to prevent the panic and make sure
proper error propagation.

Signed-off-by: Dwi Siswanto <git@dw1.io>

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-04-10 21:39:17 +05:30
Dwi Siswanto 6f2ade6a9b fix(js): respect allow-local-file-access in require (#7332)
* fix(js): respect `allow-local-file-access` in `require`

The goja `require() `function used the default
host filesystem loader which let JavaScript
templates import any local files even when
`allow-local-file-access` was disabled.

Pooled runtimes kept `require()` state around so
a module loaded during a privileged execution
could remain cached for a later restricted one.

Rebuild the require registry per execution after
setting the execution context, and route file-
backed module loads to preserve native modules
while enforcing the same sandbox rules (as
`nuclei/fs`).

Signed-off-by: Dwi Siswanto <git@dw1.io>

* fix: cross-platform sandbox path checks

Replace lexical prefix checks in the template file
sandbox with a shared path containment helper that
canonicalizes both paths before comparing them to
prevent false rejections when the configured
templates directory and the resolved file path
differ only due to symlink expansion on macOS or
path normalization on Windows.

Apply the helper in `protocolstate.NormalizePath()`
and `Options.GetValidAbsPath()` so JS `require()`-
based module loads and helper file resolution use
the same rules.

Signed-off-by: Dwi Siswanto <git@dw1.io>

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-04-10 08:06:39 +07:00
Doğan Can Bakır 10cccb7f3c fix headless JS loading with -tlsi and addheader/setheader 2026-04-02 17:44:49 +05:30
Dwi Siswanto 68e49a7981 fix(interactsh): serialize InternalEvent access
`interactsh.(*Client).processInteractionForRequest`
was updating the wrapped event under lock but
releasing it before calling `Operators.Execute()`,
allowing async interactsh updates to race with
matcher expr evaluation on the same `InternalEvent`
map, causing fatal concurrent map iteration/write
crashes.

Hold the event lock while populating interactsh
fields and running operators, and use a locked
`eventHash()` helper for matched-template cache
lookups that access the same event data.

Fixes #7319

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-04-02 11:48:33 +07:00
Doğan Can Bakır cb0a9f4621 support service names in network template port field 2026-03-26 17:49:22 +03:00
Mzack9999 9e2366f21f Merge pull request #7294 from mikhail5555/fix/data-race-condition-global-variable
Fix(clientpool): remove global variable from clientpool in favour for local variable
2026-03-25 18:48:29 +01:00
Mzack9999 a8c8645203 remove init 2026-03-25 17:56:35 +01:00
Dogan Can Bakir a86ee99ed6 Merge pull request #7292 from projectdiscovery/5350-code-execution-error-logging
capturing stderr
2026-03-24 21:12:25 +03:00
Mzack9999 233af2cd9e fix(websocket): path handling when merging template & target URLs (#7290) 2026-03-24 17:47:43 +07:00
Mikhail Epifanov 49a0ffe796 only override maxRedirects if options.MaxRedirects > 0 2026-03-24 09:33:51 +01:00
Mikhail Epifanov 9cc8456902 remove global variable from clientpool in favour for local variable 2026-03-24 09:17:53 +01:00
Mzack9999 3a004d1d46 capturing stderr 2026-03-24 00:11:41 +01:00
Mzack9999 2f03145f5d fixing redirect 2026-03-23 01:02:21 +01:00
Mzack9999 48e05ca32e Merge pull request #7277 from HarshadaGawas05/feat/honeypot-detection
feat: add honeypot detection to reduce scan noise (#6403)
2026-03-20 17:09:58 +01:00
Mzack9999 3bcf21d398 small fix 2026-03-20 16:40:42 +01:00
Mzack9999 63d0df9506 fmt + docs 2026-03-20 16:16:17 +01:00
Mzack9999 29ae75b7dc adding interface 2026-03-20 14:18:29 +01:00
Harshada Gawas 658df54f48 feat: add honeypot detection to reduce scan noise (#6403) 2026-03-20 14:05:21 +05:30
Dwi Siswanto d221732016 fix(expressions): only eval template-authored expressions (#7221)
* fix(expressions): only eval template-authored expressions

`expressions.Evaluate()` currently replaces
placeholders first and then scans the substituted
output for expressions which allows
response-derived values, including extractor
output, to be reinterpreted as DSL/helper syntax
on a second pass, which then becomes more serious
when env-backed variables are enabled.

So making this by collecting expressions from the
original template text before placeholder
substitution and then evaluating only those
original expressions after normal replacement to
keep trusted template-authored helpers working,
including placeholders nested inside helper
arguments while treating substituted response data
as literal text.

Fixes #7210

Signed-off-by: Dwi Siswanto <git@dw1.io>

* test: add resp data literal reuse test

Signed-off-by: Dwi Siswanto <git@dw1.io>

---------

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-03-16 18:25:36 +07:00
Dogan Can Bakir bc37a26d10 Merge pull request #7043 from projectdiscovery/dwisiswant0/fix/http/isolate-project-cache-keys-by-scheme-host
fix(http): isolate project cache keys by scheme & host
2026-03-16 03:35:03 +03:00
Dogan Can Bakir 979c867301 Merge pull request #7033 from projectdiscovery/fix/encoding-hides-unresolved-vars
fix(expressions): propagate unresolved variable markers through encoding functions
2026-03-10 00:46:58 +03:00
Mzack9999 870ad4607d Merge branch 'dev' into fix/encoding-hides-unresolved-vars 2026-03-05 14:33:42 +01:00
Dwi Siswanto a2e49abfab feat(http): respect annotations in unsafe mode
Apply request annotations during `unsafe` raw
request generation so @Host/@timeout/etc affect
the effective target and execution context.

Strip leading annotation directives from `unsafe`
wire bytes before sending, since `rawhttp`
transmits raw payload verbatim and annotation
lines can produce malformed HTTP requests.

Close #6747

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-03-05 13:20:07 +07:00
Dwi Siswanto 50996a7481 fix(http): isolate project cache keys by scheme & host
Prev. project keyed cache lookups from dumped HTTP
request bytes alone. For eq requests, this allowed
"http" and "https" targets to collide and reuse
cached responses across schemes.

Derive a scoped cache key by prefixing normalized
scheme://host before `projectfile.{Get,Set}`
keying input in the HTTP protocol path.

Close #6866

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-03-05 13:15:17 +07:00
Dogan Can Bakir 70ac8bf72b Merge pull request #7018 from projectdiscovery/dwisiswant0/chore/go-fix
chore: `golangci-lint run --fix ./...`
2026-03-04 16:39:33 +03:00
Doğan Can Bakır 99c2fad3f3 Merge branch 'dev' into fix/replace-panic-with-error-handling 2026-03-03 21:22:12 +03:00
Yaron Niddam 73507cde1c Merge pull request #6788 from yaron12n/expose-cluster-ids-mapping-to-template-ids
Expose cluster ids mapping to template ids
2026-02-28 04:15:36 +05:30
Dwi Siswanto 1556d08bb7 fix(headless): avoid cross-test chrome teardown races (#7053)
Drop global Chrome process sweeping from browser
shutdown.

The `previousPIDs` snapshot + delta kill logic is
unsafe on shared/parallel runners: a test can
classify another test's Chrome as "new" and kill
it during `(*Browser).Close()`, triggering
intermittent Rod panics (use of closed network
connection).

Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-02-27 10:58:23 +07:00
Dwi Siswanto c27c47420f chore: golangci-lint run --fix ./...
Signed-off-by: Dwi Siswanto <git@dw1.io>
2026-02-26 22:03:14 +07:00
Doğan Can Bakır ef650defb6 Revert "fix(lint): use fmt.Fprintf for remaining WriteString(fmt.Sprintf(...)) calls"
This reverts commit 10421e9d00.
2026-02-26 14:45:25 +03:00
Doğan Can Bakır 7ab71db320 Merge branch 'dev' into fix/encoding-hides-unresolved-vars 2026-02-25 15:43:18 +03:00