Path Traversal in MobileSafari
Safari on iOS 14.0 used the web page's title tag as a filename when saving a page as PDF, without sanitising it, allowing path traversal. An attacker could create files in Safari's container, potentially crashing Safari permanently.
Published on feed.bugs.xdavidhu.me
I have found a path traversal issue in Safari, present in iOS 14.0. When saving a web page as PDF into Files, Safari uses the page’s <title> tag as a file name, without sanitising it first, leading to path traversal.
The full write-up lives on its author's site
It belongs to its author, 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
Likely the app failed to sanitise the user-controlled page title before using it as a file path component.
Impact
An attacker could create files in Safari's container, potentially causing a permanent crash by writing a file Safari cannot parse; writes outside the app folder are blocked by the sandbox.
What the attacker needed
IOS 14.0 device; victim opens malicious page in Safari; victim saves page as PDF to Files
The fix
The issue was fixed in iOS/iPadOS 14.5 and watchOS 7.4.
How it was found
- Host an HTML page with a crafted title tag.
- Open the page in Safari.
- Tap Share.
- Tap Options, set Send As to PDF, then tap the back arrow.
- Tap Save to Files.
- Observe that a file named 'pdf' was created in Safari's Library/Preferences folder.
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.
When you save a web page as a PDF on an iPhone, Safari uses the page's title as the file name. The bug is that it doesn't clean the title, so a malicious page can include slashes and dots to make Safari save the file in a different folder than intended. This lets an attacker write files inside Safari's own storage area.
What is Path traversal?
Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.