fix(fxdk): prevent path traversal in remote resources#3920
Draft
VeinDevTtv wants to merge 1 commit into
Draft
Conversation
Fixes citizenfx#2209 Validate the FxCode remote resource path before passing it to Express sendFile. The previous route trusted the user-controlled path query forwarded through getRemoteResourcePath, allowing arbitrary absolute paths to be served by the shell backend. The route now rejects empty paths and paths that resolve outside sdkRootFXCode, preventing traversal and absolute-path reads while preserving FxCode resources under the SDK root.
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.
Summary
Fixes the FxDK
/vscode-remote-resourcepath traversal reported in #2209.The shell backend previously passed the user-controlled
pathquery throughgetRemoteResourcePath()and directly intores.sendFile(). SincesendFile()accepts absolute paths, a request such as?path=C:/Windows/win.inicould read files outside the FxDK install.Changes
sdkRootFXCodeusingpath.relative()and an absolute-path check.sendFile().This keeps the remote resource endpoint limited to the same SDK root already exposed by
/fxcode-static, while blocking arbitrary absolute-path reads and..traversal out of the FxCode root.Validation
ext/sdk/resources/sdk-root/shell/src/backend/fxcode/fxcode-service.ts...traversal.Full package build was not run because this checkout does not have
node_modules, andyarnis not installed locally.