fix: replace hardcoded Allora API key with environment variable#1033
fix: replace hardcoded Allora API key with environment variable#1033tombudd wants to merge 1 commit intocoinbase:mainfrom
Conversation
- Move DEFAULT_API_KEY from hardcoded string to process.env.ALLORA_API_KEY - Even 'public/dev' keys in source code can be scraped, abused, and cause rate-limit issues - Users should set ALLORA_API_KEY in their .env file Security audit performed by UNA — autonomous AI security auditor Built by Tom Budd (tom@tombudd.com | tombudd.com/una-reviews)
🟡 Heimdall Review Status
|
There was a problem hiding this comment.
Pull request overview
Removes the previously hardcoded Allora API key from the Allora action provider and switches configuration to be supplied via environment variables, addressing a high-severity security audit finding.
Changes:
- Replaced the hardcoded default Allora API key with
process.env.ALLORA_API_KEY. - Updated inline comments to instruct users to configure
ALLORA_API_KEY.
Comments suppressed due to low confidence (1)
typescript/agentkit/src/action-providers/allora/alloraActionProvider.ts:36
process.env.ALLORA_API_KEY || ""forcesconfig.apiKeyto become an empty string when neitherconfig.apiKeynor the env var is set. This makes the provider look configured while still using an invalid key, and can lead to confusing downstream errors. Consider aligning with other providers by settingconfig.apiKey ||= process.env.ALLORA_API_KEYand throwing a clear error if it’s still missing (or at least avoid defaulting to an empty string).
// Load API key from environment. Set ALLORA_API_KEY in your .env file.
// See https://docs.allora.network for API key registration.
const DEFAULT_API_KEY = process.env.ALLORA_API_KEY || "";
config.apiKey = config.apiKey || DEFAULT_API_KEY;
config.chainSlug = config.chainSlug || ChainSlug.TESTNET;
this.client = new AlloraAPIClient(config);
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Load API key from environment. Set ALLORA_API_KEY in your .env file. | ||
| // See https://docs.allora.network for API key registration. | ||
| const DEFAULT_API_KEY = process.env.ALLORA_API_KEY || ""; | ||
|
|
||
| config.apiKey = config.apiKey || DEFAULT_API_KEY; | ||
| config.chainSlug = config.chainSlug || ChainSlug.TESTNET; |
There was a problem hiding this comment.
The new env-var fallback for the API key isn’t covered by tests. Since this repo already has Jest tests for this provider, please add coverage that (1) ALLORA_API_KEY is used when config.apiKey is omitted, and (2) a clear error is raised when neither is provided (if you adopt the validation suggested above).
Summary
Security audit identified a hardcoded API key in the Allora action provider:
typescript/agentkit/src/action-providers/allora/alloraActionProvider.ts:32The key
UP-4151d0cc489a44a7aa5cd7efis committed in source code. Even though the comment describes it as a "public, development only key," hardcoded credentials in source code create risks:Changes
DEFAULT_API_KEYwithprocess.env.ALLORA_API_KEY || ""ALLORA_API_KEYin their.envfileFiles: 1 changed —
alloraActionProvider.ts(+3 / -3 lines)This review was performed by UNA — an autonomous AI security auditor built by Tom Budd (tom@tombudd.com | tombudd.com/una-reviews).