Security: add key management, SAST scanning, audit workflow, and RPC rate limiting - #348
Merged
ALLEN-AYODEJI merged 2 commits intoAug 28, 2026
Conversation
…rate limiting ## Summary This commit implements four security improvements: ### 1. Secure Key Management (Trellis-Ecosystem#157) - Add keystore support for secure Stellar secret key storage using OS keychains - Implement keyring integration for macOS Keychain, Linux secret-tool, Windows Credential Manager - Add new CLI commands: `trellis keys add`, `trellis keys remove`, `trellis keys list` - Display security warning when plaintext TRELLIS_SOURCE_KEY env var is detected - Provide fallback resolution: keychain > env var > literal key ### 2. SAST Scanning with Semgrep (Trellis-Ecosystem#158) - Create `.semgrep/soroban-rules.yaml` with Soroban-specific vulnerability patterns - Add rules for: unchecked auth, unchecked panic, arithmetic overflow, unsafe contract calls - Integrate Semgrep into contract CI workflow (runs on every PR) - Update CONTRIBUTING.md with local Semgrep installation and usage instructions - Pattern detection prevents common security vulnerabilities before code review ### 3. Cargo Audit Scheduled Workflow (Trellis-Ecosystem#159) - Add `.github/workflows/cargo-audit.yml` for weekly RustSec Advisory Database checks - Schedule runs every Monday at 06:00 UTC (cron: 0 6 * * 1) - Automatically detect CVEs in direct and transitive dependencies - Workflow fails when vulnerabilities are found for CI/CD integration ### 4. RPC Rate Limiting (Trellis-Ecosystem#160) - Add `governor` crate for rate limiting outbound RPC calls - Default limit: 10 requests/second (configurable via STELLAR_RPC_RATE_LIMIT env var) - Automatically queue requests that exceed the rate limit - Log warning when active rate limiting is throttling requests - Prevent unintentional RPC provider abuse in scripted workflows ## Technical Details ### Dependencies Added - \`governor = \"0.6\"\` for rate limiting - \`keyring = \"2.0\"\` for OS keychain integration ### Files Changed - \`.github/workflows/cargo-audit.yml\`: New scheduled audit workflow - \`.github/workflows/contract-ci.yml\`: Added Semgrep step - \`.semgrep/soroban-rules.yaml\`: New SAST rules - \`CONTRIBUTING.md\`: Added Semgrep section + updated section numbering - \`cli/trellis_cli/Cargo.toml\`: Added governor and keyring dependencies - \`cli/trellis_cli/src/main.rs\`: Added keystore module import - \`cli/trellis_cli/src/commands/mod.rs\`: Added Keys subcommand and handlers - \`cli/trellis_cli/src/config.rs\`: Added key resolution method - \`cli/trellis_cli/src/keystore.rs\`: New module implementing secure key management - \`cli/trellis_cli/src/rpc.rs\`: Added rate limiting with governor ## Testing - Rate limiting: verify that 100 rapid requests throttle to ~10/s - Key management: test keychain store/retrieve/remove operations - Semgrep: verify CI scan runs on contract code - Cargo audit: manual workflow dispatch should report current CVEs Closes Trellis-Ecosystem#157 Trellis-Ecosystem#158 Trellis-Ecosystem#159 Trellis-Ecosystem#160
|
@Emmyt24 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements four major security improvements for the Trellis CLI:
1. Secure Key Management (#157)
trellis keys add <identity> <key>,trellis keys remove <identity>,trellis keys listTRELLIS_SOURCE_KEYenv var is detected2. SAST Scanning with Semgrep (#158)
.semgrep/soroban-rules.yamlwith Soroban-specific vulnerability patternssemgrep --config .semgrep/ contracts/3. Cargo Audit Scheduled Workflow (#159)
4. RPC Rate Limiting (#160)
STELLAR_RPC_RATE_LIMITTesting
Dependencies
governor = "0.6"for rate limitingkeyring = "2.0"for OS keychain integrationCloses #157
Closes #158
Closes #159
Closes #160