Skip to content

feat: implement PAT token encryption at rest#2

Open
BrawlerXull wants to merge 1 commit into
open-gitagent:mainfrom
BrawlerXull:feat/encrypt-pat-tokens
Open

feat: implement PAT token encryption at rest#2
BrawlerXull wants to merge 1 commit into
open-gitagent:mainfrom
BrawlerXull:feat/encrypt-pat-tokens

Conversation

@BrawlerXull
Copy link
Copy Markdown

@BrawlerXull BrawlerXull commented May 16, 2026

Encrypt agent GitHub PAT tokens using AES-256-GCM encryption, matching the existing pattern used for cloud credentials. PAT is now sealed in storage and only decrypted when needed for GitHub operations.

Changes:

  • Add Agent.PATSealed field (encrypted via FLOW_SECRET_KEY)
  • Add Agent.GetPAT() / SetPAT() methods with backward compatibility for plaintext PAT (agents created before this change)
  • Update all PAT access points to use GetPAT()
  • Update all PAT write points to use SetPAT()
  • API handlers (test-auth, install-webhook) now decrypt on-demand
  • Build executor: decrypt PAT before passing to clone/registry-auth
  • Promote executor: decrypt PAT before GitHub operations
  • SAST executor: decrypt PAT before cloning
  • Fix Dockerfile Go version: 1.24 → 1.25 (go.mod requirement)

Backward compatibility:

  • Agents with plaintext PAT (pre-encryption) still work
  • GetPAT() falls back to plaintext field if PATSealed is empty
  • No database migration required

Testing:

  • All encryption/decryption operations tested
  • Docker build passes
  • Code compiles without errors

Fixes: #3

Encrypt agent GitHub PAT tokens using AES-256-GCM encryption, matching
the existing pattern used for cloud credentials. PAT is now sealed in
storage and only decrypted when needed for GitHub operations.

Changes:
- Add Agent.PATSealed field (encrypted via FLOW_SECRET_KEY)
- Add Agent.GetPAT() / SetPAT() methods with backward compatibility
  for plaintext PAT (agents created before this change)
- Update all PAT access points to use GetPAT()
- Update all PAT write points to use SetPAT()
- API handlers (test-auth, install-webhook) now decrypt on-demand
- Build executor: decrypt PAT before passing to clone/registry-auth
- Promote executor: decrypt PAT before GitHub operations
- SAST executor: decrypt PAT before cloning
- Fix Dockerfile Go version: 1.24 → 1.25 (go.mod requirement)

Backward compatibility:
- Agents with plaintext PAT (pre-encryption) still work
- GetPAT() falls back to plaintext field if PATSealed is empty
- No database migration required

Testing:
- All encryption/decryption operations tested
- Docker build passes
- Code compiles without errors
@BrawlerXull BrawlerXull force-pushed the feat/encrypt-pat-tokens branch from e7fdb80 to 90a9a48 Compare May 16, 2026 21:29
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.

Security: Encrypt PAT tokens at rest

1 participant