Advisory

PYSEC-2026-3585

Details, part 2 of 2. The advisory

Details

Observed output from this environment after re-running the proof after drafting:

website_mapped_link_is_symlink: True
website_positive_status: 200
website_positive_body: OUTSIDE_SECRET_MARKER
website_control_status: 404
website_control_contains_secret: False
share_zip_status: 200
share_zip_contains_secret: True
share_individual_status: 200
share_individual_body: OUTSIDE_SECRET_MARKER
cleanup_done: true

Negative/control case:

  • Requesting /missing.txt in Website mode returned HTTP 404 and did not contain OUTSIDE_SECRET_MARKER, showing the proof is not a general path traversal or test harness artifact.
  • Recursive ZIP traversal has a partial control mitigation in ZipWriter.add_dir() (cli/onionshare_cli/web/share_mode.py:593-596), but the proven variants bypass that sibling mitigation through root-level single-folder expansion and direct file streaming.

Cleanup:

  • The PoC deletes the temporary directory with shutil.rmtree(base); the audit run printed cleanup_done: true.

Impact
A remote recipient of an OnionShare Share or Website service can obtain files outside the selected shared directory if that directory contains a symlink to a readable local file. This can disclose SSH keys, browser profile data, wallet files, documents, or other local secrets readable by the OnionShare process.

The most realistic attack is a malicious archive/project/export supplied to the OnionShare user that contains a symlink to a sensitive path. If the user extracts or otherwise obtains that directory and shares it with OnionShare, the recipient can request the symlink path through Website mode, Share individual-file mode, or receive it inside the default Share ZIP in the single-folder root-symlink case.

The issue is especially surprising because one ZIP code path already tries to skip symlinks recursively, which suggests symlink dereference outside the shared tree is not intended.

Suggested remediation
Reject symlinks and enforce canonical containment both when building the file map and immediately before opening/streaming/zipping a file:

  • In SendBaseModeWeb.set_file_info(), do not add paths where os.path.islink(path) is true.
  • Track selected root directories as canonical Path.resolve() values and require every served/zipped file's resolved path to remain under one of those roots.
  • Re-check the resolved path immediately before open() in stream_individual_file() and before ZipWriter.add_file() / ZipWriter.add_dir() to avoid symlink-swap/TOCTOU surprises.
  • Add regression tests for:
  • Website mode serving a root-level symlink.
  • Website mode serving a nested symlink.
  • Share default /download ZIP for a single selected folder containing a symlink.
  • Share --no-autostop-sharing individual-file symlink download.
  • Existing recursive ZIP symlink skip behavior.

Sources & licences