fix(security): remove hardcoded PAT, fix API key in URL, upgrade KDF, fix bearer casing#6147
Closed
Aamod-Dev wants to merge 1 commit into
Closed
Conversation
… fix bearer casing - Remove hardcoded GitHub PAT from .env.local - Move Gemini API key from URL query param to x-goog-api-key header in burnout-analyzer.ts and architecture/route.ts - Replace SHA-256 KDF with PBKDF2 (600k iterations) in crypto.ts - Remove plaintext token from parseAndEncryptTokens return value - Fix lowercase 'bearer' to RFC-compliant 'Bearer' across all files - Redact token from clone error log in architecture/route.ts - Add input validation to decryptToken
Contributor
|
@Aamod-Dev is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
Contributor
|
👋 Hey @Aamod-Dev! Thanks for your contribution! 🎉 Unfortunately, this PR has been automatically closed because it is not linked to any open issue. To resolve this, please do the following:
We look forward to reviewing your PR once an issue is linked! 🚀 |
| await execFilePromise('git', ['clone', '--depth', '1', '--', cloneUrl, tempDir]); | ||
| } catch (err) { | ||
| console.error('Cloning failed for repository:', repoUrl, err); | ||
| console.error('Cloning failed for repository:', repoUrl.replace(/https:\/\/x-access-token:[^@]+@/, 'https://<token>@'), err); |
This was referenced Jun 21, 2026
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 fixes several security vulnerabilities discovered during a comprehensive codebase audit related to issue #5857.
Changes
🔴 Critical
Hardcoded GitHub PAT removed —
.env.localcontained a live GitHub Personal Access Token (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). Replaced with a placeholder.Gemini API key moved from URL to header — Both
services/github/burnout-analyzer.tsandapp/api/architecture/route.tswere passing the API key as a URL query parameter (?key=${apiKey}). URLs get logged by proxies, CDNs, and server access logs. Moved to thex-goog-api-keyheader.Weak KDF replaced —
lib/crypto.tsused plain SHA-256 for encryption key derivation. SHA-256 is fast (billions of attempts/second on GPU) and designed for integrity, not key derivation. Replaced with PBKDF2 (600,000 iterations, SHA-512).🟠 High
Non-compliant
bearertoken casing — All Authorization headers used lowercasebearerinstead of RFC 6750-compliantBearer. Fixed across 5 files:lib/github.tsservices/github/pr-insights.tsservices/github/ci-analytics.tsservices/github/burnout-analyzer.tsToken leak in clone error log —
app/api/architecture/route.tslogged the fullrepoUrl(including embedded GitHub token) on clone failure. Now redacted.Plaintext token in return value —
lib/github-token-encryption.jsparseAndEncryptTokens()returned both plaintexttokenandencryptedToken. Removed plaintext field (function is currently unused, but this prevents future leaks).decryptToken input validation —
lib/crypto.tsdecryptToken()had no validation on payload format. Added length check to prevent unhandled auth tag failures.Files Changed
.env.localapp/api/architecture/route.tslib/crypto.tslib/github-token-encryption.jslib/github.tsbearer→Bearerservices/github/burnout-analyzer.tsbearer→Bearerservices/github/pr-insights.tsbearer→Bearerservices/github/ci-analytics.tsbearer→Bearer