Skip to content

Validate weight file paths stay within the model directory#8714

Open
adilburaksen wants to merge 1 commit into
tensorflow:masterfrom
adilburaksen:node/validate-weight-path
Open

Validate weight file paths stay within the model directory#8714
adilburaksen wants to merge 1 commit into
tensorflow:masterfrom
adilburaksen:node/validate-weight-path

Conversation

@adilburaksen
Copy link
Copy Markdown

In tfjs-node, NodeFileSystem.loadWeights (tfjs-node/src/io/file_system.ts) joins each path from the model's weights manifest onto the model directory and reads it, without verifying the result stays inside that directory. The manifest is untrusted input, so a path containing .. or an absolute path can read a file outside the model directory.

This resolves each weight file path and requires it to remain within the model directory before reading. Relative paths under the model directory are unaffected.

In tfjs-node, NodeFileSystem.loadWeights joins each weightsManifest path
from the model's weights manifest onto the model directory and reads it,
without checking that the result stays inside that directory. Because the
manifest is untrusted input, a path containing '..' or an absolute path
could read a file outside the model directory.

Resolve each weight file path and require it to remain within the model
directory before reading it.
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