fix(plugin-keychain-vault): return boolean from has() to stop leaking secret value
Summary
Fixes #4206.
PluginKeychainVault.has() was declared as Promise<boolean> but actually returned the entire node-vault read() response object (which contains the secret value under data.data.value). The HTTP has-keychain-entry endpoint then put that object straight into the isPresent field of its JSON response, so any caller of the presence-check endpoint received the plaintext secret of the queried key — without ever calling get-keychain-entry.
This PR makes has() discard the response and return a real boolean. Presence is now determined purely by whether read() resolved or rejected with 404. No secret material escapes the has() boundary.
Change
packages/cactus-plugin-keychain-vault/src/main/typescript/plugin-keychain-vault.ts
async has(key: string): Promise<boolean> {
const path = this.pathFor(key);
try {
await this.backend.read(path);
return true;
} catch (ex) {
if (ex?.response?.statusCode === HttpStatus.NOT_FOUND) {
return false;
}
this.log.error(`Presence check of "${key}" crashed:`, ex);
throw ex;
}
}
Two-line behavioural change. The 404 → false and rethrow branches are unchanged.
Why this matters
- Confidentiality / information disclosure in a security-critical plugin. The keychain is the trust anchor for credential material used by the connectors above it (Fabric/Besu/Ethereum signing keys, SATP-Hermes oracle keys, etc.).
- RBAC bypass. Deployments that hardened
get-keychain-entryand lefthas-keychain-entrymore broadly accessible were silently exposing every secret to every caller of the presence endpoint. - Audit gap. SIEM rules counting secret reads via
get-keychain-entryunder-reported by design — everyhas-keychain-entrycall was a covert read of the same data. - OpenAPI contract violation.
HasKeychainEntryResponseV1.isPresentis typedbooleanin the generated clients. JS clients doingif (resp.isPresent)happened to work because objects are truthy, but=== truechecks, schema validators, and strongly-typed clients (Java/Go/Rust) were all broken. - Default code path. This fired on every successful
has()call against an existing key — not an edge case.
Test plan
- [ ] Store a secret via
set-keychain-entry, then callhas-keychain-entryfor the same key. Confirm the response body is{ \"isPresent\": true, \"checkedAt\": \"…\", \"key\": \"…\" }and that no Vault response object / secret value appears anywhere in the body. - [ ] Call
has-keychain-entryfor a key that does not exist. Confirm{ \"isPresent\": false, … }. - [ ] Trigger an unrelated Vault failure (e.g. wrong token) and confirm the endpoint surfaces the error rather than masking it.
- [ ] Run the existing keychain-vault test suite and confirm it still passes (and ideally extend it with a
has()regression test that asserts the return type is a primitive boolean).
@LordKubaya Could you please take a look and share your review on this PR when you get a chance? Thanks!