Fix SSRF class URL validation gaps and harden command/file trust boundaries#4
Fix SSRF class URL validation gaps and harden command/file trust boundaries#4000boil wants to merge 2 commits intorohunvora:mainfrom
Conversation
Harden URL and path validation plus execution boundaries to reduce SSRF and unsafe command/file behaviors.
rohunvora
left a comment
There was a problem hiding this comment.
Thanks for tightening the trust boundaries here. I do think there are still a few blocking issues before this should merge:
-
scripts/security.ts:openUrlInBrowser()still usescmd /c starton Windows. That means untrusted input is still reachingcmd.exe, so the command-injection risk is not fully removed on Windows. -
scripts/ensure-key.ts+scripts/security.ts:normalizeTrustedBaseUrl()now rejects documented self-hostedPASTE_TRADE_URLvalues and silently falls back tohttps://paste.trade. That is a behavior regression, and worse, it can route tokens/data to production when the user explicitly configured another host. If we block custom bases, this should fail closed, not silently rewrite to prod. -
scripts/extract.ts: the SSRF hardening only validates the initial URL string, but the laterfetch(...)calls still follow redirects. An attacker-controlled HTTPS URL can still redirect to a loopback/private target after passing the initial check, so the SSRF fix is incomplete. -
scripts/security.ts:ensurePathInsideDir()usesresolvedFile.startsWith(${resolvedDir}/), which breaks on Windows becausepath.resolve()returns backslash-separated paths. That will reject valid nested files under the runtime source directory on Windows.
I’d be comfortable re-reviewing after those are addressed.
Fix windows browser-open execution path, fail closed on invalid base URL config, enforce safe redirect handling for article/image fetches, and make path boundary checks cross-platform. Made-with: Cursor
|
thanks done |
|
Thanks for the hardening work here. I ended up landing a broader maintainer patch for URL validation, redirect-safe fetches, non-shell browser opening, and path containment. That supersedes the intended fix here and avoids the remaining issues and regressions in this branch, so I won't be merging this one. |
this fixes a few security holes around url intake and local execution flows.
i blocked unsafe url targets/schemes at intake (ssrf hardening) and replaced risky urlopen behavior with safer process handling, locked base url trust so tokens don’t get routed to shady hosts, restricted helper scripts to read files only from intended runtime dirs, and tightened url input handling where commandbound extraction happens.
untrusted input was crossing network/process/filesystem trust boundaries wich was not great lol cuz it lowers backend request abuse risk, unsafe exec risk, and local secret exposure risk.
ur welcome :p