A3:2021 | Path Transversal (8) | Cycubix Docs
Solution
As mentioned in the previous page, this is what happens when you create a zip file with an image inside:
Now let’s upload this as our profile image. We can see nothing happens as mentioned in the assignment there is a bug in the software, and the result we see on the screen is:
Let’s create a zip file that traverses to the top and then back into the given directory in the assignment.
First, create the directory structure:
Now, if we upload this zip file, it solves the assignment.
Troubleshooting with PowerShell
Create the directory with the following code:
Download the image:
Create the Zip file with File Transversal:
Run the script command:
Upload profile.zip into the previous lesson.
Why did this work?
In the code, the developers used the following fragment:
The fix is to make sure the resulting file in line 5 resides in the directory you expect. Same as with the path traversal mitigation, use profilePicture.getCanonicalPath()
to ensure the path is the same as you expect it to be.
The getCanonicalPath()
method resolves the absolute path, eliminating any path traversal sequences.
The getCanonicalPath()
method resolves the absolute path, eliminating any path traversal sequences.
Last updated