Skip to content

fix: add authentication to IPFS upload endpoint (#4171)#4173

Open
aglichandrap wants to merge 1 commit into
IntersectMBO:developfrom
aglichandrap:fix/ipfs-upload-auth-4171
Open

fix: add authentication to IPFS upload endpoint (#4171)#4173
aglichandrap wants to merge 1 commit into
IntersectMBO:developfrom
aglichandrap:fix/ipfs-upload-auth-4171

Conversation

@aglichandrap
Copy link
Copy Markdown

Fix for #4171 - Unauthenticated Arbitrary File Pinning via Pinata API

Problem

The POST /ipfs/upload endpoint was completely unauthenticated, allowing any anonymous user to pin arbitrary content to Intersect's Pinata account. This is a security vulnerability that enables:

  • Abuse of Pinata storage quota
  • Potential storage of malicious/illegal content on Intersect's account
  • Uncontrolled API usage costs

Solution

Added API key authentication to the /ipfs/upload endpoint using an Authorization: Bearer <key> header.

Changes

Backend (Haskell):

  • VVA/Config.hs: Added ipfsUploadApiKey configuration field
  • VVA/Types.hs: Added UnauthorizedError to AppError type (returns HTTP 401)
  • VVA/API.hs:
    • Added Header "Authorization" Text to the upload route type
    • Added API key validation in the upload handler
    • Fails closed: rejects all uploads when no API key is configured
  • app/Main.hs: Maps UnauthorizedError to HTTP 401 status
  • example-config.json: Added ipfsuploadapikey field

Frontend (TypeScript):

  • config/env.ts: Added VITE_IPFS_UPLOAD_API_KEY environment variable
  • services/requests/postIpfs.ts: Sends Authorization: Bearer <key> header

Deployment

  1. Set ipfsuploadapikey in backend config (or VVA_IPFSUPLOADAPIKEY env var)
  2. Set VITE_IPFS_UPLOAD_API_KEY in frontend environment

Closes #4171

The POST /ipfs/upload endpoint was completely unauthenticated, allowing
any anonymous user to pin arbitrary content to Intersect's Pinata account.

Changes:
- Add API key configuration (ipfsuploadapikey) to backend config
- Require Authorization: Bearer <key> header on /ipfs/upload
- Add UnauthorizedError (401) to AppError type
- Fail closed when no API key is configured
- Update frontend to send API key via VITE_IPFS_UPLOAD_API_KEY env var
- Update example-config.json with new ipfsuploadapikey field

Fixes IntersectMBO#4171
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 [Bounty] - Unauthenticated Arbitrary File Pinning to Intersect's Paid Pinata Account via POST /ipfs/upload

1 participant