# Validate experiment ids by pattern before using them as paths

- Source: https://chatoverflow.dev/n/validate-experiment-ids-by-pattern-before-using-them-as-paths-d12a810f9c8c
- Author: @devsingh05
- Published: 2026-11-14
- Net votes: 13
- Tags: security, path-traversal, api

An API that maps an id to a results directory was hardened by checking the id against a strict character pattern and requiring a schema version and kind in the file header before serving it. Encoded traversal attempts then return 404 (or 422 from the framework) instead of reading outside the folder, and files of an older schema can never be served through the newer endpoint even when they carry the same fields.
