starknet_transaction_prover: add TLS integration tests#14050
starknet_transaction_prover: add TLS integration tests#14050avi-starkware wants to merge 1 commit into
Conversation
|
Warning This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
This stack of pull requests is managed by Graphite. Learn more about stacking. |
PR SummaryLow Risk Overview New
Reviewed by Cursor Bugbot for commit 02903ed. Bugbot is set up for automated code reviews on this repo. Configure here. |
| -----BEGIN PRIVATE KEY----- | ||
| MIIEvQIBADANBgkqhkiG9w0BAQEFAASCBKcwggSjAgEAAoIBAQCcDEcAhUbdyBnU |
There was a problem hiding this comment.
Semgrep identified an issue in your code:
Hard-coded private key in source code allows attackers who gain repository access to impersonate your service or decrypt sensitive data.
More details about this
This code contains a hard-coded private key embedded directly in your source code. An attacker who gains access to your repository—whether through a compromised developer account, leaked source code, or cloned Git history—would immediately obtain this private key.
Here's a concrete attack scenario:
-
Attacker gains repository access: A developer's GitHub account is compromised, or the repo is accidentally made public, exposing the code containing the
-----BEGIN PRIVATE KEY-----block. -
Attacker extracts the key: The attacker copies the entire private key (the base64-encoded
$KEYcontent between the BEGIN/END markers). -
Attacker impersonates your service: Using this private key, the attacker can:
- Sign JWTs or other tokens to forge authentication credentials
- Decrypt data encrypted with the corresponding public key
- Establish TLS connections pretending to be your service
- Access any system that trusts this key for authentication
-
Lateral movement: If this key is used to authenticate to cloud services, databases, or internal APIs, the attacker now has a foothold into your infrastructure.
The danger is that this exposure is permanent—even if you delete the key from your repo now, it remains in Git history and anyone with repository access can retrieve it.
To resolve this comment:
✨ Commit fix suggestion
- Remove the entire private key block from your codebase, including everything from
-----BEGIN PRIVATE KEY-----to-----END PRIVATE KEY-----. - Store the private key in a secure location outside your source code, such as a private file on the server, a secure secrets manager, or environment variable.
- Update your application to load the private key at runtime from the secure location instead of from the code. For example, use
fs.readFileSync('/path/to/private.key')in Node.js, or reference an environment variable that points to the file path. - Add the filename or pattern for private keys (such as
*.keyor the specific key file) to your.gitignorefile to prevent accidental commits in the future.
💬 Ignore this finding
Reply with Semgrep commands to ignore this finding.
/fp <comment>for false positive/ar <comment>for acceptable risk/other <comment>for all other reasons
Alternatively, triage in Semgrep AppSec Platform to ignore the finding created by detected-private-key.
You can view more details about this finding in the Semgrep AppSec Platform.
There was a problem hiding this comment.
/fp Test fixture only. Cert subject is CN=localhost (SAN: DNS:localhost,IP:127.0.0.1); used exclusively by src/server/tls_test.rs to exercise start_tls_server and load_tls_acceptor. Provenance and regeneration command documented in resources/test_tls/README.md. The key is not referenced from any production code path.
3bf5954 to
8600ded
Compare
b062874 to
1d6f06e
Compare
8600ded to
96bf8d9
Compare
6377a5b to
6a4087a
Compare
96bf8d9 to
056f406
Compare
056f406 to
3a5608b
Compare
6a4087a to
44827d2
Compare
Adds end-to-end HTTPS tests against a self-signed test certificate checked into resources/test_tls/: a successful HTTPS JSON-RPC roundtrip on starknet_specVersion, a plain-HTTP-against-TLS-server negative test, and unit tests around load_tls_acceptor covering missing cert/key paths, invalid PEM contents, and the happy path. To allow co-located tests in tls_test.rs to call it, load_tls_acceptor is bumped from private to pub(crate); no API surface is exposed outside the crate.
44827d2 to
02903ed
Compare
3a5608b to
38dd27c
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, have a team admin enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 02903ed. Configure here.
|
|
||
| let response = client | ||
| .post(format!("https://localhost:{}", addr.port())) | ||
| .json(&spec_version_request()) |
There was a problem hiding this comment.
Client URL mismatches bind address
Medium Severity
The TLS server is bound to 127.0.0.1, but the integration tests post to https://localhost:… and http://localhost:…. On hosts where localhost resolves to ::1 first, nothing listens on that address, so the HTTPS case can fail flakily and the HTTP negative case may error with connection refused instead of exercising plain HTTP against a TLS listener.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 02903ed. Configure here.



Adds end-to-end HTTPS tests against a self-signed test certificate
checked into resources/test_tls/: a successful HTTPS JSON-RPC roundtrip
on starknet_specVersion, a plain-HTTP-against-TLS-server negative test,
and unit tests around load_tls_acceptor covering missing cert/key
paths, invalid PEM contents, and the happy path.
To allow co-located tests in tls_test.rs to call it, load_tls_acceptor
is bumped from private to pub(crate); no API surface is exposed
outside the crate.