Skip to content

Feat/cosmos enigma utils OK-50764 OK-50786 OK-50962#10456

Merged
originalix merged 8 commits intoxfrom
feat/cosmosEnigmaUtils
Mar 5, 2026
Merged

Feat/cosmos enigma utils OK-50764 OK-50786 OK-50962#10456
originalix merged 8 commits intoxfrom
feat/cosmosEnigmaUtils

Conversation

@ByteZhang1024
Copy link
Contributor

@ByteZhang1024 ByteZhang1024 commented Mar 4, 2026

@revan-zhang
Copy link
Contributor

revan-zhang commented Mar 4, 2026

Snyk checks have passed. No issues have been found so far.

Status Scanner Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues
Licenses 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@ByteZhang1024 ByteZhang1024 force-pushed the feat/cosmosEnigmaUtils branch from ce2cf6b to 2f869e2 Compare March 4, 2026 01:57
@ByteZhang1024 ByteZhang1024 changed the title Feat/cosmos enigma utils OK-50764 OK-50786 Feat/cosmos enigma utils OK-50764 OK-50786 OK-50962 Mar 5, 2026
@ByteZhang1024 ByteZhang1024 force-pushed the feat/cosmosEnigmaUtils branch from 2f869e2 to 7649397 Compare March 5, 2026 03:50
@ByteZhang1024 ByteZhang1024 marked this pull request as ready for review March 5, 2026 04:52
devin-ai-integration[bot]

This comment was marked as resolved.

@ByteZhang1024 ByteZhang1024 enabled auto-merge (squash) March 5, 2026 04:56
chatgpt-codex-connector[bot]

This comment was marked as resolved.

@ByteZhang1024 ByteZhang1024 force-pushed the feat/cosmosEnigmaUtils branch from 2640845 to 1f0691f Compare March 5, 2026 05:28
Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 2 new potential issues.

View 7 additional findings in Devin Review.

Open in Devin Review

Comment on lines +773 to +781
@providerApiMethod()
public async getEnigmaPubKey(
request: IJsBridgeMessagePayload,
params: { chainId: string },
): Promise<string> {
const utils = await this._getOrCreateEnigmaUtils(request, params.chainId);
const pubkey = await utils.getPubkey();
return bytesToHex(pubkey);
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🔴 Missing @permissionRequired() decorator on Enigma provider methods breaks security pattern

All existing Cosmos provider methods that perform sensitive cryptographic operations (signAmino, signDirect, sendTx, signArbitrary, verifyArbitrary) are decorated with @permissionRequired() to ensure the dApp has an approved connection before proceeding. The four new Enigma methods (getEnigmaPubKey, enigmaEncrypt, enigmaDecrypt, enigmaGetTxEncryptionKey) perform cryptographic operations using the user's private key-derived seed but lack this decorator. While _getOrCreateEnigmaUtils internally calls _getAccountgetAccountsInfo which may fail for unconnected dApps, the missing decorator breaks the defense-in-depth pattern established throughout the codebase. The CLAUDE.md rule states: "Crypto operations MUST follow established patterns" and "Transaction verification and risk detection MUST NOT be bypassed".

Prompt for agents
Add the @permissionRequired() decorator to all four Enigma provider methods in packages/kit-bg/src/providers/ProviderApiCosmos.ts to match the existing pattern used by signAmino, signDirect, sendTx, signArbitrary, and verifyArbitrary. Specifically, add @permissionRequired() before @providerApiMethod() on the following methods:
1. getEnigmaPubKey (line 773)
2. enigmaEncrypt (line 783)
3. enigmaDecrypt (line 793)
4. enigmaGetTxEncryptionKey (line 806)
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbf22ef6b2

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment on lines +748 to +752
if (!password) {
const result = (await this.backgroundApi.serviceDApp.openModal({
request,
screens: [
EModalRoutes.DAppConnectionModal,

Choose a reason for hiding this comment

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

P2 Badge Fail fast on unsupported wallets before password prompt

_getOrCreateEnigmaUtils asks for a password before checking whether the current keyring can derive an Enigma seed, but VaultCosmos.getEnigmaSeed throws for unsupported wallet types (e.g., hardware/watching). In that scenario, users are forced through an unlock modal and then still get a hard failure, which is a dead-end flow for those wallets; the support check should happen before opening the unlock modal.

Useful? React with 👍 / 👎.

@socket-security
Copy link

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Added@​babel/​plugin-proposal-class-properties@​7.18.61001006550100
Added@​babel/​plugin-proposal-class-static-block@​7.21.01001007150100
Added@​babel/​plugin-proposal-nullish-coalescing-operator@​7.18.61001007050100
Added@​babel/​plugin-proposal-private-property-in-object@​7.21.111001007350100
Added@​aptos-labs/​ts-sdk@​1.39.09710010050100
Added@​babel/​plugin-transform-numeric-separator@​7.25.91001006794100
Added@​expo/​plist@​0.1.3741007199100
Added@​types/​node-fetch@​2.6.91001007281100
Added@​bottom-tabs/​react-navigation@​1.1.0941007396100
Added@​aptos-labs/​siwa@​0.4.0771007387100
Added@​babel/​preset-typescript@​7.27.11001007394100
Addedesbuild@​0.27.2911007390100
Updated@​babel/​plugin-transform-optional-chaining@​7.27.1 ⏵ 7.25.9100 +110074 +194100
Added@​formatjs/​intl-pluralrules@​4.3.31001007492100
Addedexpo-keep-awake@​14.1.4741008299100
Added@​formatjs/​intl-locale@​2.4.471001007592100
Added@​formatjs/​intl-getcanonicallocales@​1.9.21001007692100
Added@​babel/​preset-env@​7.28.6971007795100
Added@​glif/​filecoin-rpc-client@​3.0.27710010081100
Added@​benfen/​bfc.js@​0.2.7821007789100
Added@​alephium/​web3@​1.5.292100779670
Added@​babel/​core@​7.27.1971008095100
Added@​glif/​filecoin-message@​2.0.44801008184100
Added@​electron/​remote@​2.1.110010010081100
Added@​cityofzion/​neon-core@​5.7.0861008186100
Added@​ckb-lumos/​ckb-indexer@​0.23.08110010083100
Added@​emurgo/​cardano-message-signing-nodejs@​1.0.1911008285100
Added@​cowprotocol/​contracts@​1.7.0881001008470
Added@​ckb-lumos/​common-scripts@​0.23.08310010083100
Added@​electron/​notarize@​2.3.210010010083100
Added@​aivenio/​tsc-output-parser@​2.1.19910010084100
Added@​glif/​filecoin-address@​2.0.43841008584100
Added@​conflux-dev/​conflux-address-js@​1.3.16881009284100
See 8 more rows in the dashboard

View full report

@socket-security
Copy link

Warning

Review the following alerts detected in dependencies.

According to your organization's Security Policy, it is recommended to resolve "Warn" alerts. Learn more about Socket for GitHub.

Action Severity Alert  (click "▶" to expand/collapse)
Warn Critical
Critical CVE: Elliptic's private key extraction in ECDSA upon signing a malformed input (e.g. a string)

CVE: GHSA-vjh7-7g9h-fjfh Elliptic's private key extraction in ECDSA upon signing a malformed input (e.g. a string) (CRITICAL)

Affected versions: < 6.6.1

Patched version: 6.6.1

From: ?npm/elliptic@6.5.4

ℹ Read more on: This package | This alert | What is a critical CVE?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Remove or replace dependencies that include known critical CVEs. Consumers can use dependency overrides or npm audit fix --force to remove vulnerable dependencies.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/elliptic@6.5.4. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

Warn High
Obfuscated code: npm @emurgo/cardano-message-signing-asmjs is 90.0% likely obfuscated

Confidence: 0.90

Location: Package overview

From: ?npm/@emurgo/cardano-message-signing-asmjs@1.0.1

ℹ Read more on: This package | This alert | What is obfuscated code?

Next steps: Take a moment to review the security alert above. Review the linked package source code to understand the potential risk. Ensure the package is not malicious before proceeding. If you're unsure how to proceed, reach out to your security team or ask the Socket team for help at support@socket.dev.

Suggestion: Packages should not obfuscate their code. Consider not using packages with obfuscated code.

Mark the package as acceptable risk. To ignore this alert only in this pull request, reply with the comment @SocketSecurity ignore npm/@emurgo/cardano-message-signing-asmjs@1.0.1. You can also ignore all packages with @SocketSecurity ignore-all. To ignore an alert for all future pull requests, use Socket's Dashboard to change the triage state of this alert.

View full report

Copy link
Contributor

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 1 new potential issue.

View 9 additional findings in Devin Review.

Open in Devin Review

new PolyfillCryptoProvider(),
);
const plaintext = new TextEncoder().encode(
contractCodeHash + JSON.stringify(msg),
Copy link
Contributor

Choose a reason for hiding this comment

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

🟡 JSON.stringify() used for cryptographic encryption plaintext, violating CLAUDE.md rule

CLAUDE.md explicitly states: "NEVER use JSON.stringify() for cryptographic operations → ALWAYS use stringUtils.stableStringify() for deterministic serialization". At SecretNetworkEncryption.ts:84, JSON.stringify(msg) is used to serialize the message object before AES-SIV encryption, which is a cryptographic operation. While the security impact is minimal (this is encryption plaintext, not a hash/signature input), and JSON.stringify matches the secret.js reference implementation for protocol compatibility, it is an explicit violation of the repository's mandatory rules.

Note on protocol compatibility

The Secret Network protocol and secret.js reference implementation use standard JSON.stringify. Switching to stableStringify could change key ordering and break compatibility with Secret Network contracts. If this is intentional for protocol compatibility, it should be documented with a comment explaining the exception.

Suggested change
contractCodeHash + JSON.stringify(msg),
// NOTE: Using JSON.stringify (not stableStringify) intentionally to match
// the Secret Network / secret.js wire format for contract message encoding.
contractCodeHash + JSON.stringify(msg),
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

@originalix originalix disabled auto-merge March 5, 2026 06:36
@originalix originalix merged commit 4e5b37e into x Mar 5, 2026
11 checks passed
@originalix originalix deleted the feat/cosmosEnigmaUtils branch March 5, 2026 06:36
PatrickChoo pushed a commit to PatrickChoo/app-monorepo that referenced this pull request Mar 10, 2026
* feat: support cosmos enigma utils

* feat: update CosmosEnigmaUnlockModal

* feat: support unisat asset api

* chore: update onekey inprovider version

* fix: add type declarations for miscreant to fix tsgo build error

* fix: resolve lint errors in miscreant types, ProviderApiBtc, and SecretNetworkEncryption

---------

Co-authored-by: Leon <lixiao.dev@gmail.com>
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.

3 participants