Skip to content

fix(paths): build room, engine and pipeline paths through checked helpers - #3390

Merged
kunal0137 merged 2 commits into
devfrom
fix-snyk-sast-path-guards
Nov 25, 2026
Merged

kunal0137 merged 2 commits into
devfrom
fix-snyk-sast-path-guards

Conversation

@kunal0137

@kunal0137 kunal0137 commented Nov 25, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Follow-up to #3388 for the Snyk Code rows that are still open after the rescan. The values in these flows were already checked, but with boolean checks Snyk does not follow (isSafePathSegment before building the path). This builds the paths through helpers that normalize the path, confirm it stays in its folder and return the checked path, the same pattern that cleared the Teams and delegation rows in #3388.

Changes

  • Utility.childPath(folder, name, what): one name under a folder. Refuses blank, ., .., /, \, NUL and NFKC forms that turn into those; the result must be a direct child of the folder. Returns the same string form as folder + File.separator + name.
  • Utility.pathWithin(folder, relative, what): a relative path, sub folders allowed. Refuses absolute paths, NFKC changes and anything that leaves the folder or equals it, compared on real paths, so a symlink in the folder (or the file itself being a link) cannot lead outside it.
  • Both helpers refuse a blank folder, and a name the file system rejects (e.g. : on Windows) is logged and refused like any other bad value.
  • Used in:
    • Room.roomFolderPath (room folder for insights, cloud push, transcripts)
    • UploadUtilities.getEngineTempSmssLoc (temp .smss)
    • InternalUtility.getEngineDetails (engine folder and .owl file)
    • ExternalAuthorizationHelper (engine folder for externally granted engines)
    • EngineProxyFactory.pipelineFile (PIPELINE file in the engine assets folder)
  • UploadUtilities.validateEngine and getEngineTempSmssLoc check the engine id and name on their own before anything is written, since the unique name normalizes away segments such as ...
  • ExternalAuthorizationHelper: one external engine that cannot be written is logged and skipped, the rest of the sync goes on.
  • MicrosoftOneDriveHelper.download: only the temp file it named is moved or deleted; the path returned by the HTTP helper must be that same file.

Snyk rows this targets (about 21)

  • Agent runtime path traversal: AgentToolDecisionHandler (7), AgentRunQueueLoop 184/186/336, AgentRunService 803, AssessAgentEffectivenessReactor 153, HumanDelegationService 533, SemossAgentHarness 349
  • ExternalAuthorizationHelper 116/119/121/126/128
  • MicrosoftTeamsHelper 381 (path traversal)

Not changed here, to be ignored with reasons: SSRF on Graph pre-authenticated links (https checked, host is dynamic), AgentsMdLoader (project folder after the edit-permission check), SecretsUtility AES-CBC (needs a separate design), HttpHelperUtility and LinOTP (by design).

Behaviour changes

  • A PIPELINE value that is not a file inside the engine assets folder (a .. path or a symlink out of it) is logged with the engine id and the engine is refused, the same as when its pipeline file cannot be read; it does not run without its guardrails. A leading slash is still ignored, as before, and a missing file is still an engine with no guardrails. The guardrail config reactors get an error for such a value.
  • An engine id or name that is not a single safe name (e.g. containing / or ..) now fails with "Not a valid engine name/id" when the engine is created, before any folder is made. Previously such a name produced a nested or escaping path.

Testing

  • mvn compile passes.
  • Small Java check of the helpers: normal room ids, engine names with spaces and nested pipeline paths pass; .., a/b, a full-width slash, /etc/passwd, ../../, sub/.., a blank folder, a pipeline file that is a link out of the folder, a dangling link and a linked sub folder are refused.
  • Not run live. Whether Snyk drops each row is confirmed on the next scan.

@kunal0137
kunal0137 requested a review from a team as a code owner November 25, 2026 20:14
@snyk-io

snyk-io Bot commented Nov 25, 2026 •

Copy link
Copy Markdown
Contributor

✅ Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
✅ Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

…ting

- pathWithin resolves real paths, so a symlink in the folder cannot lead outside it
- both helpers refuse a blank folder and log names the file system rejects
- an invalid PIPELINE value refuses the engine instead of running it without guardrails
- validateEngine and the temp smss check the engine id and name on their own
- one external engine that cannot be written is skipped, the sync goes on
- null checks for the PIPELINE value and the OneDrive download result
@kunal0137
kunal0137 merged commit 845255a into dev Nov 25, 2026
4 checks passed
@kunal0137
kunal0137 deleted the fix-snyk-sast-path-guards branch November 25, 2026 21:32
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.

1 participant