fix(api): require CID ownership to unpin IPFS content (IDOR) - #1172
Merged
Ejirowebfi merged 7 commits intoAug 25, 2026
Conversation
POST /api/ipfs/unpin previously authorized any wallet with a valid JWT to unpin any CID, since a fresh JWT costs nothing (challenge/response needs no on-chain history) and the wallet address was never checked against who actually pinned the content. Add a pin-ownership registry (api/_lib/pinOwnership.ts) populated by upload-json.ts / upload-file.ts at pin time, and a new unpin.ts endpoint that resolves a CID back to its pinning wallet before calling Pinata. A CID with no ownership record is denied by default rather than allowed, and every attempt (allowed or rejected) is audit-logged with address, cid, and outcome. Closes Favourorg#1155
PR Favourorg#1049 bumped react to 19.2.8 but left react-dom pinned to 19.2.7, which React now hard-errors on at runtime ("Incompatible React versions"), breaking the entire frontend test suite and blocking the pre-push hook.
…-idor # Conflicts: # api/ipfs/unpin.test.ts # api/ipfs/unpin.ts # api/ipfs/upload-file.ts # api/ipfs/upload-json.ts # frontend/package-lock.json # frontend/package.json
…on merge The two-step admin-rotation change landed with a contract that does not compile, so Contract Build, Contract Tests and Rust Formatting all fail on this branch's merge of main. - `BatchSizeExceeded`, `NoPendingProposal` and `ProposalExpired` were all assigned discriminant 24 (E0081). Renumber them 25/26/27 and update the error tables in docs/contract-abi.md and README.md. - `test.rs` called `Ledger::with_mut` without importing the trait (E0599). - Apply `cargo fmt`. Two test failures the compile error had been masking: - `migrate`: the v3 `TokenInfo` walk is chunked and may still be mid-flight, but the new v4 step ran unconditionally and pushed the version marker to 4. Every later `migrate` call then skipped the v3 block, stranding the entries beyond the cursor in instance storage — exactly what the v3 chunking comment warns against. Return early while v3 is incomplete. - `accept_admin` cleared an expired proposal and then returned `ProposalExpired`; the error reverts the invocation, so the write never persisted. Drop the dead write and state the real behaviour: an expired proposal stays on record but is inert, and the admin cancels or re-proposes. Docs and the test now assert that. Regenerate the test snapshots, which were stale from the same merge. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFDD5GssS1ik3KcH3XMx43
`Contract/Frontend Drift` fails because `CONTRACT_TOPIC_MAP` still carries the retired single-step `adm_upd` topic and is missing `fee_redir`. The contract now emits `adm_prop`, `adm_acc` and `adm_can` for a rotation, so every admin event was being dropped from Transaction History and CSV exports. Map all four topics, decode their payloads (including `adm_prop`'s expiry ledger and `fee_redir`'s skipped recipient and amount), and update the regression tests with real XDR fixtures for each. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01HFDD5GssS1ik3KcH3XMx43
`check-access-control-docs-drift.sh` stripped `//` comments with a naive
regex, so `if &buf[..7] != b"ipfs://" {` lost its opening brace and the brace
counter closed `set_metadata` forty lines early. The truncated body hid the
`creator != admin` guard, and the check exited 1 — failing the workflow.
Strip line comments with a scanner that skips string literals, add a rule for
the stored-creator identity check, and correct `set_metadata`'s expected
claims: it authorizes its caller and compares them against the token's stored
creator, and factory-admin privilege grants nothing there.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HFDD5GssS1ik3KcH3XMx43
`cargo clippy -- -D warnings` failed on `collapsible_if` in the fee distribution loop. Collapsing into `share > 0 && ...is_err()` keeps the short-circuit semantics: the transfer is still only attempted for a non-zero share. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_019E8cJSSGUUPiea6LFYL8wN
|
🎉 This PR is included in version 1.8.3 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
POST /api/ipfs/unpinpreviously authorized any request that presented a valid JWT — since a fresh JWT is free to obtain (no on-chain history required), any wallet could unpin any other user's IPFS metadata by CID.api/_lib/pinOwnership.ts) populated at upload time byupload-json.ts/upload-file.ts, and a newapi/ipfs/unpin.tsendpoint that resolves a CID back to the wallet that pinned it before calling Pinata.SECURITY.mdunder "Known security considerations".frontend/package.jsonhadreactbumped to 19.2.8 (chore(deps): bump react from 19.2.7 to 19.2.8 in /frontend #1049) withoutreact-dom, which hard-errors at runtime and broke the entire frontend test suite / this repo'spre-pushhook. Alignedreact-domto 19.2.8 so the branch could be pushed through the hook cleanly.Test plan
npx vitest run api/ipfs/unpin.test.ts— 6/6 passing: owner unpins own CID (allow), non-owner denied (403), unindexed CID denied by default (403), malformed cid rejected (400), missing JWT rejected (401), non-POST rejected (405)npm test -- --runinfrontend/— 609/609 passing after the react-dom fixCloses #1155