Skip to content

Conversation

@alexcos20
Copy link
Member

@alexcos20 alexcos20 commented Feb 3, 2026

Fixes #762

Changes proposed in this PR:

  • require signature for encrypt and encryptFiles endpoints
  • ocean.js and ocean-cli already updated

@alexcos20 alexcos20 linked an issue Feb 3, 2026 that may be closed by this pull request
@alexcos20 alexcos20 marked this pull request as ready for review February 3, 2026 09:00
@alexcos20 alexcos20 self-assigned this Feb 3, 2026
@alexcos20
Copy link
Member Author

/run-security-scan

Copy link
Member Author

@alexcos20 alexcos20 left a comment

Choose a reason for hiding this comment

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

AI automated code review (Gemini 3).

Overall risk: high

Summary:
This pull request introduces signature-based authentication and policy server integration for the /api/services/encrypt and /api/services/encryptFile endpoints. It updates documentation, command types, handler logic, HTTP routes, policy server methods, and tests to incorporate these new security and policy features.

Comments:
• [ERROR][security] The if (auth) check around the auth.validateAuthenticationOrToken call introduces a critical security vulnerability. If this.getOceanNode().getAuth() returns null or undefined (e.g., if the authentication component is not initialized or configured), the entire authentication and signature validation logic will be bypassed. This would allow unauthenticated requests to proceed to the encrypt and encryptFile handlers, which are intended to be secured.

Authentication should be mandatory for these commands. The auth object should either always be present (and getAuth() should throw if it's not) or the validateTokenOrSignature method should explicitly return a 401 error if auth is missing, rather than silently skipping validation.
• [WARNING][documentation] The encrypt command policy server payload is updated in src/components/policyServer/index.ts to include consumerAddress and policyServer fields. This change is not reflected in the docs/PolicyServer.md. Please add the updated JSON structure for the encrypt action, similar to how encryptFile is documented.
• [WARNING][bug] The encryptHandler.validate and encryptFileHandler.validate tests only assert that removing the blob or rawData property makes the command invalid. However, EncryptCommand and EncryptFileCommand now also require nonce, consumerAddress, and signature. The unit tests for the .validate() method should explicitly confirm that omitting any of these newly required fields also results in an invalid command. The .validate() method should perform comprehensive schema validation for all required fields.

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Command: encrypt - Add user signature

2 participants