-
Notifications
You must be signed in to change notification settings - Fork 19
add signature for encrypt handlers #1189
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
base: main
Are you sure you want to change the base?
Conversation
|
/run-security-scan |
alexcos20
left a comment
There was a problem hiding this 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.
Fixes #762
Changes proposed in this PR:
encryptandencryptFilesendpoints