ReadiumShared links the whole marmelroy/Zip library although only the Minizip C module is imported

Open
#897 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
5/5
Estimated time
Over a week
Newbie friendliness
45/100
Issue type
Refactor
Clarity
Mostly clear
Activity status
Active
Tech stack
c, swift

Research direction

Start with Package.swift and Sources/Shared/Toolkit/ZIP/Minizip/MinizipContainer.swift, then compare the dependency options described in the issue; the issue notes that Minizip was deliberately restored in #551 and #548. Confirm the chosen approach with maintainers before starting, since the issue asks for direction; done means downstream apps no longer link the Swift Zip library, with the ZIP opener choice unchanged.

Written by the indexing model from the issue text.

Description

ReadiumShared declares "Zip" — the Swift library product of marmelroy/Zip — as a target dependency, but the only module the toolkit imports from that package is the C target Minizip. The Swift wrapper is therefore compiled and linked into every downstream app, and it carries CVE-2023-39135 with no fixed version in existence.

To be explicit about what we are not claiming: we do not say the vulnerable path is reachable from Readium. It is not — the traversal is in the Swift on-disk unzip helper, which the toolkit never calls. The cost is elsewhere: every downstream app's Package.resolved pins a package with a permanently unfixable high-severity advisory, and there is no version to move to, so each dependency scan has to be answered by hand, forever.

What is actually imported

swift-toolkit 3.11.0 (d82f44f4f05d87add9e22a8b75abbd61dce745dd), and unchanged on current develop:

  • Package.swift:27 — .package(url: "https://github.com/marmelroy/Zip.git", from: "2.1.2") (develop:22)
  • Package.swift:42 — "Zip" among the dependencies of target ReadiumShared (develop:33)
  • the only import from that package anywhere in Sources/: Sources/Shared/Toolkit/ZIP/Minizip/MinizipContainer.swift:8 — import Minizip
  • grep -rn "^import Zip" Sources/ — no match

Minizip is reachable only transitively: marmelroy/Zip exposes a single product, .library(name: "Zip", targets: ["Zip"]), and Minizip is a target underneath it (Zip/Package.swift:8-23).

What ends up in the binary

Measured with nm over the payload of our shipping app (Xcode 26, iOS 26 simulator, Debug):

nm fancai.debug.dylib | grep -c ' T _$s3Zip'       ->  57   exported Swift `Zip` symbols
nm fancai.debug.dylib | grep -c '$s3Zip'           -> 205   all `Zip` module symbols
nm fancai.debug.dylib | grep -cE ' T _(unz|zip)'   ->  56   minizip C functions, the part you use
The advisory

GHSA-g454-wj9r-jpg4 / CVE-2023-39135, severity high, "Path traversal in Zip Swift":

vulnerable_version_range: <= 2.1.2
first_patched_version:    null

2.1.2 is the newest tag of marmelroy/Zip, published 2022-02-23, and the repository's last push is 2024-08-05T18:42:46Z (api.github.com/repos/marmelroy/Zip, checked 2026-09-13). There is nothing to update to, and no sign that there will be.

Ask

Stop shipping the Swift Zip library to downstream apps. Any of these closes it, in our order of preference:

  1. Vendor the minizip C sources into the toolkit — for instance a ReadiumMinizip C target — and drop the marmelroy/Zip package dependency entirely. This is the only option that also removes the pin from downstream Package.resolved.
  2. Take minizip from a maintained distribution instead.
  3. If the sources must keep coming from that package, ask upstream to expose Minizip as its own product and depend on .product(name: "Minizip", package: "Zip"). That removes the Swift code from the link, but Package.resolved would still carry the advisory.

We know Minizip is back deliberately (#551, #548) and stays until the ZIPFoundation ArchiveOpener is battle-tested — this issue is only about where those C sources come from, not about the choice of opener.

We can prepare a PR for option 1 if that is the direction you would take.

Dominant language
Swift
Stars
557
Forks
249
Avg merge
3h 52m
Merged PRs (30d)
19

Getting set up

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from readium/swift-toolkit

All issues in readium/swift-toolkit

Similar issues

More Swift issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.