Skip to content

Conversation

@standujar
Copy link
Collaborator

No description provided.

…rect order

- Added functionality to encrypt both settings.secrets and root-level secrets when agents are added or updated.
- Updated tests to verify encryption and decryption of secrets, including handling of empty and mixed-type secret values.
- Ensured that non-string secret values are preserved during the encryption process.
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Dec 10, 2025

Important

Review skipped

Auto reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Note

Other AI code review bot(s) detected

CodeRabbit has detected other AI code review bot(s) in this pull request and will avoid duplicating their findings in the review comments. This may lead to a less comprehensive review.

✨ Finishing touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/secrets

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@standujar standujar changed the title fix: implement encryption for character secrets in ElizaOS in the cor… fix: encryption for character secrets in correct order Dec 10, 2025
@claude
Copy link
Contributor

claude bot commented Dec 10, 2025

Claude encountered an error —— View job


I'll analyze this and get back to you.

@claude

This comment was marked as outdated.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a critical security bug where environment variables merged into character secrets were not being encrypted. The fix ensures that secrets are encrypted in the correct order: first merge environment variables, then encrypt all secrets.

Key Changes

  • Encryption order corrected: Secrets are now encrypted AFTER environment variables are merged, ensuring all sensitive data (including env vars) is properly encrypted
  • Support for root-level secrets: Added encryption handling for character.secrets in addition to character.settings.secrets
  • Removed premature encryption: Removed the encryptedCharacter() wrapper call in server/index.ts that was encrypting secrets before env var merging

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
packages/server/src/index.ts Removed premature encryptedCharacter() call and import, allowing encryption to happen at the correct time in elizaos.ts
packages/server/src/api/agents/crud.ts Added encryption for both character.secrets and character.settings.secrets in POST and PATCH handlers; moved salt declaration outside conditional blocks for reuse
packages/core/src/elizaos.ts Added encryption logic after environment variable merging in addAgents() to ensure all secrets including env vars are encrypted
packages/core/src/__tests__/elizaos.test.ts Added comprehensive test suite covering encryption of settings.secrets, root-level secrets, edge cases, and encryption format validation

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@claude
Copy link
Contributor

claude bot commented Dec 10, 2025

Claude finished @standujar's task —— View job


PR Review: Encryption for Character Secrets

Todo List:

  • Read and analyze all changed files
  • Check for security issues (hardcoded keys, SQL injection, XSS)
  • Verify test coverage and quality
  • Check TypeScript compliance and imports
  • Look for architectural issues and breaking changes
  • Provide actionable review feedback

Code Review Summary

This PR implements encryption for character secrets at multiple levels (root and settings.secrets) with comprehensive test coverage and proper TypeScript handling.

PASSED: Test coverage is excellent with 209 new tests covering all encryption scenarios
PASSED: Uses bun:test correctly (not jest/vitest)
PASSED: TypeScript compliance - proper types and imports
PASSED: Security - no hardcoded secrets, proper encryption implementation
PASSED: Architecture follows existing patterns and ElizaOS conventions

💡 SUGGESTION: TypeScript strictness → Consider: Remove type assertions in server/index.ts:273-290 for better type safety

The implementation is solid and follows project conventions. The encryption logic properly handles both character.secrets and character.settings.secrets locations, with comprehensive tests validating the functionality.

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@wtfsayo wtfsayo merged commit 7cb2193 into develop Dec 10, 2025
8 of 17 checks passed
@wtfsayo wtfsayo deleted the fix/secrets branch December 10, 2025 17:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

1.x V2 bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants