Skip to content

Commit

Permalink
[ fix ] Prevent relative path traversal in elaborator scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
AlgebraicWolf authored and gallais committed Oct 16, 2023
1 parent c04404a commit 3e5d8a5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/TTImp/Elab/RunElab.idr
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ elabScript rig fc nest env script@(NDCon nfc nm t ar args) exp
pathDoesNotEscape _ [] = True
pathDoesNotEscape Z (".."::rest) = False
pathDoesNotEscape (S n) (".."::rest) = pathDoesNotEscape n rest
pathDoesNotEscape n ("." ::rest) = pathDoesNotEscape n rest
pathDoesNotEscape n (_ ::rest) = pathDoesNotEscape (S n) rest

elabCon : Defs -> String -> List (Closure vars) -> Core (NF vars)
Expand Down
5 changes: 5 additions & 0 deletions tests/idris2/reflection/reflection024/src/LessSimpleRW.idr
Original file line number Diff line number Diff line change
Expand Up @@ -35,3 +35,8 @@ failing "path must not escape the directory"

-- Check a slightly more complicated case of escaping
%runElab readAndLog "nonExistentOriginally/../../whatever"

failing "path must not escape the directory"

-- Check that '.' does not allow escaping
%runElab readAndLog "./../whatever"

0 comments on commit 3e5d8a5

Please sign in to comment.