Skip to content

Conversation

@google-labs-jules
Copy link
Contributor

This PR fixes the failing tests and build errors in PR 1533 by refactoring the key management and updating the tests.


PR created automatically by Jules for task 9014872671383561964 started by @hulto

claude and others added 4 commits January 5, 2026 06:09
This commit implements JWT-based authentication for gRPC APIs:

- Added JWT service using persistent ed25519 keys for signing
- Updated protobufs to include JWT fields in:
  - Task (returned from ClaimTasks)
  - ReportTaskOutputRequest
  - FetchAssetRequest
  - ReportCredentialRequest
  - ReportFileRequest
- Updated ClaimTasks to generate JWTs for each claimed task
- Added JWT validation to gRPC APIs:
  - ReportTaskOutput
  - FetchAsset
  - ReportCredential
  - ReportFile
- Invalid JWTs are logged with task ID and JWT token as warnings

The ed25519 keys are stored persistently in the secrets manager,
separate from the x25519 keys used for encryption.
…nd ECDH

This commit refactors the key management to use a single ed25519 master
key for both JWT signing and ECDH key exchange:

Changes:
- Created keyservice package to manage the master ed25519 key
- Implemented ed25519 to x25519 key derivation following RFC 7748
  - Private key: hash ed25519 seed and apply Curve25519 clamping
  - Public key: convert Edwards curve point to Montgomery curve
- Updated JWT service to accept keys instead of managing its own
- Updated app.go to use keyservice for both JWT and cryptocodec
- Removed duplicate key generation functions (generateKeyPair, getKeyPair, etc.)
- Removed separate storage keys:
  - Old: tavern_jwt_ed25519_private_key (JWT only)
  - Old: tavern_encryption_private_key (ECDH only)
  - New: tavern_master_ed25519_key (both JWT and derived ECDH)

Benefits:
- Single source of truth for cryptographic keys
- Ed25519 master key enables both signing (JWT) and ECDH (x25519)
- Simpler key management with one persistent key
- Maintains backward compatibility with existing x25519 ECDH protocol
Updated all test files that create C2 servers to include the JWT
service parameter that was added in the previous commits:

- internal/c2/c2test/grpc.go: Test helper for C2 tests
- internal/c2/reverse_shell_e2e_test.go: E2E reverse shell test
- internal/portals/integration_test.go: Portal integration tests
- internal/portals/benchmark_test.go: Portal benchmark tests

Each test now generates ephemeral ed25519 keys and creates a JWT
service before initializing the C2 server, matching the updated
c2.New() signature.
This commit addresses the failing tests and build errors by:
- Refactoring the key management to use a centralized KeyService.
- Updating the status handler and tests to use the new KeyService.
- Updating the claim tasks test to ignore the dynamic JWT field.
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@hulto hulto force-pushed the claude/jwt-ed25519-keys-Avusa branch from e9f7451 to e6813fc Compare January 6, 2026 22:48
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.

2 participants