fix: address path traversal vulnerability and false warnings in config file handlers - #1449
Open
ankita10119 wants to merge 6 commits into
Open
fix: address path traversal vulnerability and false warnings in config file handlers#1449ankita10119 wants to merge 6 commits into
ankita10119 wants to merge 6 commits into
Conversation
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #1449 +/- ##
==========================================
- Coverage 80.36% 80.22% -0.15%
==========================================
Files 163 163
Lines 7595 7619 +24
Branches 1677 1686 +9
==========================================
+ Hits 6104 6112 +8
- Misses 797 811 +14
- Partials 694 696 +2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
harshithRai
approved these changes
Aug 6, 2026
harshithRai
left a comment
Contributor
There was a problem hiding this comment.
LGTM, provided v9 (#1448) lands the hard-error enforcement as I see it does there, since this only warns.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
🔧 Changes
Background and motivation
This PR addresses two related problems reported against the 8.x release line:
1. Security vulnerability (SEC-23449) - path traversal
Resource configurations (
actions,actionModules,rules,hooks,databases) reference external code files by path. A malicious or misconfigured path such as../../sensitive-file.jscould cause the CLI to load a file from outside the intended config directory. This is a path traversal vulnerability reported by the security team.2. False deprecation warnings on legitimate relative paths (issue #1432)
Users reported that the CLI was incorrectly emitting deprecation warnings for valid relative paths such as
./actions/action-one/code.js. Investigation confirmed the root cause: the actions and actionModules handlers were using a fragile regex to pre-process paths before passing them toloadFile(), andloadFile()itself had a silentisFilefallback (isFile(inSubfolder) ? inSubfolder : inRoot) that behaved unpredictably depending on whether the file existed at the expected location.These two problems share the same root cause: inconsistent and fragile path resolution logic across handlers.
Root cause
databases.tsalready had the correct approach, it usedpath.resolve + startsWith(configRoot)directly in the handler. However,actions.tsandactionModules.tsused a regex to strip path prefixes before delegating toloadFile():The regex incorrectly stripped the
./prefix, causingloadFile()to resolve against the wrong base path and trigger false warnings for valid paths.rules.tsandhooks.tspassed paths directly toloadFile()without any pre-processing, relying on theisFilefallback which could silently load the wrong file.Edge cases identified and addressed
./, causing misresolution. Fixed by resolving directly from context.filePath using path.resolve.configRoot/rules/inrules.tsandconfigRoot/hooks/inhooks.ts.loadFile()- On Unix,path.join(base, absolutePath)silently discards the base. Fixed by usingpath.resolve()throughout, which handles absolute paths correctly.loadFile()tried inSubfolder, and if the file didn't exist there, silently fell back to inRoot with no error or warning, potentially loading the wrong file. Removed entirely, path is now resolved deterministically with no fallback.AUTH0_ALLOW_EXTERNAL_CODE_PATHSescape hatch (see below).What changed
actions.ts/actionModules.ts: Replaced regex pre-processing +loadFile()delegation with an explicitpath.resolve+ startsWith check, directly callingloadFileAndReplaceKeywords. Now consistent withdatabases.ts.rules.ts/hooks.ts: ReplacedloadFile()delegation with the same inlinepath.resolve+startsWithcheck.directory/index.ts(loadFile()): Removed theisFilefallback. Emits a deprecation warning when path resolves outside config root. This will become a hard error inv9.0.0.yaml/index.ts(loadFile()): Same fix - emits a deprecation warning when path resolves outside config root.databases.ts: Detection logic was already correct; updated to supportAUTH0_ALLOW_EXTERNAL_CODE_PATHSconsistently with other handlers.types.ts: AddedAUTH0_ALLOW_EXTERNAL_CODE_PATHS?: booleanto the Config type.docs/configuring-the-deploy-cli.md: Added documentation forAUTH0_ALLOW_EXTERNAL_CODE_PATHSincluding the monorepo use case, directory structure example, upgrade guidance, and security notice.AUTH0_ALLOW_EXTERNAL_CODE_PATHSescape hatchIntroduces an explicit opt-in config flag for monorepo setups where code files legitimately reside outside the config root directory. When set to true, the deprecation warning is suppressed and the file loads successfully. When not set (default), a deprecation warning is emitted, users seeing this warning should move their files inside the config directory before upgrading to
v9.0.0, where this will be enforced as a hard error.AUTH0_ALLOW_EXTERNAL_CODE_PATHSflag.This flag was introduced solely to support the monorepo use case described above. However, it bypasses the path traversal protection. The security team should confirm whether this escape hatch is acceptable and under what conditions it should be permitted. Full context is documented in
docs/configuring-the-deploy-cli.md.📚 References
Unit tests have been added or updated for all affected handlers:
test/context/directory/actions.test.js: Added tests for valid relative paths (no warning), path traversal warning, escape hatch (AUTH0_ALLOW_EXTERNAL_CODE_PATHS), and Windows-style backslash paths.test/context/directory/rules.test.js: Added test asserting a deprecation warning is emitted when script path resolves outside config root.test/context/directory/hooks.test.js: Added test asserting a deprecation warning is emitted when script path resolves outside config root.All 25 tests in the above files pass.
🔬 Testing
Manual testing:
../../ traversal- verify the deprecation warning fires and the deploy continues (8.xbehavior)../actions/action-one/code.js) - verify it deploys with no warning.AUTH0_ALLOW_EXTERNAL_CODE_PATHS: truewith an external path - verify it loads successfully with no warning.📝 Checklist