Skip to content

fix: add path traversal validation to datapoints endpoints#2610

Open
q1uf3ng wants to merge 1 commit intoPAIR-code:mainfrom
q1uf3ng:fix/path-traversal-validation
Open

fix: add path traversal validation to datapoints endpoints#2610
q1uf3ng wants to merge 1 commit intoPAIR-code:mainfrom
q1uf3ng:fix/path-traversal-validation

Conversation

@q1uf3ng
Copy link
Copy Markdown

@q1uf3ng q1uf3ng commented May 8, 2026

Summary

_save_datapoints and _load_datapoints in app.py pass user-supplied file paths directly to open() without validation. A path like ../../etc/passwd reads or writes arbitrary files on the server.

Fix

Add _validate_data_path() that resolves paths with os.path.realpath() and rejects anything outside the configured data_dir.

Reproduction

# With LIT server running:
requests.post('http://localhost:5432/save_datapoints', json={
    'dataset_name': 'sst_dev', 'path': '../../tmp/stolen',
    'inputs': [{'text': 'test'}]
})

@google-cla
Copy link
Copy Markdown

google-cla Bot commented May 8, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@q1uf3ng
Copy link
Copy Markdown
Author

q1uf3ng commented May 8, 2026

I have already signed the Google CLA. Please recheck.

User-supplied paths in _save_datapoints and _load_datapoints are passed
directly to file I/O without validation. An attacker can use path
traversal sequences to read or write arbitrary files on the server.

Add _validate_data_path() that resolves the path and ensures it stays
within the configured data_dir.
@q1uf3ng q1uf3ng force-pushed the fix/path-traversal-validation branch from 94a7ffd to cd09e6c Compare May 8, 2026 05:59
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