Semantics of `mkFsPath` inconsistent between instances and vulnerable in IO

Aperta
#100 0 commenti 1 reazione 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
5/5
Tempo stimato
Più di una settimana
Idoneità per principianti
35/100
Tipo di issue
Bug
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
haskell

Direzione di ricerca

Iniziate leggendo la descrizione di FsPath e gli entry point mkFsPath e fsPathToFilePath, confrontando il comportamento dei file system reali e simulati. Definite e verificate l’escaping specifico della piattaforma, in modo che i percorsi rimangano contenuti nel punto di montaggio e coerenti tra le istanze, incluso l’esempio ["/", "etc", "passwd"].

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

The semantics of mkFsPath are inconsistent between the real and simulated filesystem instances, as is documented in the description of FsPath.
This inconsistency makes it easy to write code that behaves differently depending on whether or not it runs on a real or simulated filesystem.
This makes it nigh-impossible to write code that is truly known to be invariant over what kind of filesystem it will be evaluated on, since the segments of the FsPath will be interpreted differently by the different instances.
Notably, the code mkFsPath ["/", "etc", "passwd"] will yield an FsPath that is well-behaved in the simulation, but yields a path to /etc/passwd when evaluated with the actual filesystem, regardless of the mount point.

tmpDir <- Dir.getTemporaryDirectory
let mountPoint = tmpDir </> "fs-sim"
let hasFS = ioHasFS (MountPoint mountPoint)
let passwd = mkFsPath ["/", "etc", "passwd"]
putStrLn (unsafeToFilePath passwd)
-- "/etc/passwd"
-- NOT: "/tmp/fs-sim/etc/passwd"

This breaks the encapsulation that the mount point is intended to introduce and introduces an attack vector that can be exploited by any FsPath created from user input or by an unreviewed version of a dependency.
Furthermore, fs-api significantly obfuscates the dangers here.

In my opinion, the fsPathToFilePath function that is used to interpreted FsPath on the real filesystem should escape all characters that have special meaning on the current platform in order to yield consistent behaviour across the API instances and better encapsulation.

Lingua principale
Haskell
Stelle
2
Fork
6
Metriche di merge delle PR
Nessuna PR unita negli ultimi 30g

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di IntersectMBO/fs-sim

Tutte le issue di IntersectMBO/fs-sim

Issue simili

Altre issue su Haskell

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.