Skip to content
Path traversal Write-up Beginner

Google Code Playground - Path Traversal

The Google Code Playground proxy script stripped a fixed prefix from the request path and then joined it to a base directory without normalising the result, so a crafted path containing a double-dot sequence could escape the intended directory. An attacker could read arbitrary files on the server, such as the application's main Python file.

Michał Bentkowski Follow

Published on blog.bentkowski.info

The original lives on blog.bentkowski.info

We do not hold its text, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The script removed a fixed prefix from the request path and then joined it to a base directory without normalising or validating the result, allowing '..' sequences to traverse out of the intended directory.

Impact

An attacker could read arbitrary files on the server that the application process had permission to access, potentially exposing source code and other sensitive data.

What the attacker needed

Access to the Google Code Playground site; ability to send crafted HTTP requests

The fix

The issue was fixed the same day, as shown by the linked diff.

How it was found

  1. Request a normal path such as /apis/ajax/playground/samples/test.html to see the expected behaviour.
  2. Craft a path that includes a double-dot sequence after the prefix, for example /apis/ajax/playground/samples/..apis/ajax/playground//main.py.
  3. Observe that the prefix removal leaves a '..' in the remaining path.
  4. The server joins the remaining path to the base directory, which resolves to a file outside the intended folder.
  5. The contents of that file are returned in the HTTP response.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

A web server often builds a file path by taking part of the URL and adding it to a folder on disk. If the URL contains '..' (which means 'go up one folder'), the server can be tricked into reading files outside that folder. Here the code removed a fixed prefix but did not clean up the remaining path, so a specially crafted URL let the attacker read any file the server could access.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

More by Michał Bentkowski

View all

15 more disclosed reports, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.