cacti icon indicating copy to clipboard operation
cacti copied to clipboard

fix(weaver): avoid temp file authz risks in corda sdk

Open malsomesh9 opened this issue 7 months ago • 4 comments

Summary

Fix the Corda Weaver credentials extractor so certificate PEM content is serialized in memory instead of being written to temporary filesystem paths first.

Changes

  • replace file-based PEM round-tripping with in-memory PEM encoding
  • remove temporary certificate directory creation and cleanup from CredentialsExtractor
  • keep the extracted config output shape unchanged while removing the flagged improper resource access pattern

Verification

  • Reviewed the affected code path in weaver/sdks/corda end-to-end
  • Attempted local Gradle verification, but this machine does not currently have a Java runtime installed, so GitHub CI is the authoritative validation for this PR

Fixes #2768

malsomesh9 avatar Apr 06 '26 17:04 malsomesh9

Maintainer note: this addresses issue #2768 by removing the file-system round trip in CredentialsExtractor and encoding PEM data directly in memory, so the flagged improper resource access path is no longer exercised.

Verification attempted locally in an isolated worktree, but this machine does not currently have a Java runtime installed, so I could not start the module's Gradle tasks here. GitHub CI is therefore the authoritative validation for this PR.

malsomesh9 avatar Apr 06 '26 17:04 malsomesh9

Thanks for this fix. It looks good to me, but I want to ensure that the relevant tests are passing. @sandeepnRES can you check the CI and ensure that Weaver Corda SDK changes are covered by the tests that are enabled and which have passed?

VRamakrishna avatar Apr 15 '26 12:04 VRamakrishna

Thanks for this fix. It looks good to me, but I want to ensure that the relevant tests are passing. @sandeepnRES can you check the CI and ensure that Weaver Corda SDK changes are covered by the tests that are enabled and which have passed?

The CI does run it, but those generated certs aren't used I think. @malsomesh9 can you please confirm by running following test:

  1. Run end to end data sharing test from documentation page: https://hyperledger-cacti.github.io/cacti/weaver/getting-started/test-network/setup-local/, then go on to ledger initialization and testing both data-sharing and asset-transfer. Post the logs of both runs here (just the final CLI output completing the flow).

  2. Then do a git diff weaver/samples/corda/corda-simple-application/clients/src/main/resources/config/credentials and share the reponse here.

sandeepnRES avatar Apr 21 '26 17:04 sandeepnRES

`Thanks. I can address the two code-level review points in CredentialsExtractor:

switch the failure check from configObj to nodeConfigObj after getNodeIdCertChain(...) guard alias handling with ks.isKeyEntry(alias) plus null/length checks on getCertificateChain(alias)

malsomesh9 avatar Apr 29 '26 12:04 malsomesh9