Grokking Advanced Go
0% completed
Safe File Access with os Root
The order service stores each customer's invoice as a file in one directory, and a function returns a file by name. A customer supplies the name, and the program below supplies one that nobody planned for.
Output:
1001.txt: "order 1001: 2500 cents\n" <nil> ../secrets.txt: "payment key: k-77\n" <nil>
The function works as written, and it has just returned a file from outside its directory. How can a program require that a set of file operations stay inside one directory, with no way for a name to break that rule?
Path Traversal
A file name that contains `..
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%