Skip to content

feat: private gateway #180

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

feat: private gateway #180

wants to merge 9 commits into from

Conversation

fforbeck
Copy link
Member

@fforbeck fforbeck commented Jul 2, 2025

Private Gateway: KMS Integration for Encrypted Content Access

This PR implements the private gateway for handling encrypted content access through a dedicated freeway deployment.

Key Features

Google KMS Integration: Complete RSA key pair setup per space with automatic key generation, integrity validation, and proper space DID mapping.

UCAN Invocation for Encryption Setup: Implementation of space/encryption/setup capability with plan validation and KMS key provisioning for paid users.

UCAN Invocation for Symmetric Key Decryption: Handler for processing symmetric key decryption requests with proper authorization validation and space ownership checks.

Security: Server-side CRC32C validation, standardized error handling, and compliance with Google Cloud KMS security standards.

This enables secure, encrypted content storage and access control for private spaces through a dedicated freeway gateway deployment.

Sequence Diagram: https://gist.github.com/fforbeck/be6486223b387b67f319ba113901da9f

TODO

  • Revocation Check will be added in another PR
  • Verification if a given space is provided will also be done in a different PR
  • Fix broken tests
  • Code Audit & Fixes

Code Audit

  • Security Posture Summary

    • Critical vulnerabilities: ✅ ALL RESOLVED
    • High-priority vulnerabilities: ✅ 5/7 RESOLVED (71% complete, 1 deferred)
    • Medium-priority vulnerabilities: ✅ 4/5 RESOLVED (80% complete, 1 deferred)
    • Low-priority vulnerabilities: ⚠️ 0/2 IMPLEMENTED (all pending)
    • Remaining blockers: 1 critical security control (revocation checking)
  • Report: https://hackmd.io/@fforbeck/H1T7k9YBel

Closes

@fforbeck fforbeck requested a review from hannahhoward July 2, 2025 00:25
@fforbeck fforbeck self-assigned this Jul 2, 2025
@fforbeck fforbeck requested review from alanshaw and BravoNatalie July 3, 2025 20:20
@fforbeck fforbeck marked this pull request as ready for review July 3, 2025 20:20
@fforbeck fforbeck force-pushed the feat/priv-gateway branch from 7b7730a to 5004424 Compare July 8, 2025 18:48
Copy link
Member

@hannahhoward hannahhoward left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Generally LGTM. Maybe this is a naive question, but at this point, are freeway and the encryption service really the same thing? What I'm asking is the "private gateway" isn't really a gateway no? It's just a key encryption setup + decrypter? And it might be easier to run it out of Amazon where it's right next to the relevant DB tables.

Again, want to keep it moving, but I also want to understand if there is a vision to actually use the "private gateway" as a gateway? (or is that to handle the server side decryption if/when we support it)

}

// Log as structured JSON
console.log(JSON.stringify(entry))
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we confident the console.log is going somewhere that's preserved?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I guess I need set up some worker log config to preserve it. I will double-check that. Thanks for flagging.

@fforbeck
Copy link
Member Author

Generally LGTM. Maybe this is a naive question, but at this point, are freeway and the encryption service really the same thing? What I'm asking is the "private gateway" isn't really a gateway no? It's just a key encryption setup + decrypter? And it might be easier to run it out of Amazon where it's right next to the relevant DB tables.

Again, want to keep it moving, but I also want to understand if there is a vision to actually use the "private gateway" as a gateway? (or is that to handle the server side decryption if/when we support it)

Yes. They are different services. This architecture came from initially planning server-side decryption, but I pivoted to client-side key decryption without rethinking the infrastructure to get this rolling faster.

I would suggest a two-phase approach:

  1. Validate first: Let's deploy on the current freeway infrastructure at private.storacha.link - quick to market, focus on DMAIL integration
  2. Optimize later: Then we migrate to AWS (near DBs) with just a DNS change (DMAIL Integration Phase 2) - users see no difference

WDYT?

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.

3 participants