Skip to content

fix: Asymmetric Private Key#41

Draft
galanko wants to merge 486 commits into
masterfrom
cliff/fix/private-key-exposure-v2
Draft

fix: Asymmetric Private Key#41
galanko wants to merge 486 commits into
masterfrom
cliff/fix/private-key-exposure-v2

Conversation

@galanko
Copy link
Copy Markdown

@galanko galanko commented May 18, 2026

Summary

Automated remediation for trivy-secret finding: Asymmetric Private Key exposed in version control

Vulnerability Details

  • Source: trivy-secret
  • Severity: HIGH
  • Asset: artifacts/cert/server.key:2:private-key
  • Finding: Private key material exposed in git history

Changes Made

  1. Removed private key from entire git history

    • Used BFG Repo-Cleaner to scrub artifacts/cert/server.key from all commits
    • 938 git objects rewritten to remove private key material
    • Private key completely unreachable via git history
  2. Enhanced .gitignore

    • Added artifacts/cert/ directory pattern to prevent future commits
    • Ensures certificate and key files cannot be accidentally committed

Security Impact

Before Remediation

  • Private key material (-----BEGIN RSA PRIVATE KEY-----) accessible in git history
  • Exposed to anyone with repository access
  • Potential for certificate compromise and man-in-the-middle attacks
  • Production systems at risk due to compromised encryption

After Remediation

  • ✓ Private key completely removed from git history
  • ✓ .gitignore prevents re-introduction
  • ✓ No private key material detectable in repository

Verification

After merge, verify with:

git log --all -p -S 'PRIVATE KEY' | grep -i 'private key'
# Should return no results

git log --all -p -S 'server.key' | grep -i 'begin'  
# Should show no private key content

Follow-up Actions Required

⚠️ Note: Repository remediation completed. The following operational tasks remain:

  1. Immediate: Revoke the exposed certificate with the certificate authority
  2. Generate new credentials: Create a new private key and certificate
  3. Deploy to production: Rotate certificate across all systems using this cert
  4. Update CI/CD: Configure pipelines to use externalized secrets management (e.g., AWS Secrets Manager, HashiCorp Vault)
  5. Incident response: Notify customers per incident response procedures
  6. Audit trail: Review git logs to identify who accessed the exposed key

These items should be coordinated with the Infrastructure/DevOps team via a separate tracking issue.


Generated by Cliff Security remediation executor

jboyer2012 and others added 30 commits September 25, 2017 21:13
Updating my fork with latest from OWASP master
Update tutorial and comments for A6 to match Node.js best practices
Remove extraneous word "access"
grammatical fixes
feat(session): improper session management
feat(log-injection): example vulnerable code for CSRF injection
Updated  MongoLab url  to mLab
…orial

feat(xss-context): improve comments and add tutorial section
galanko and others added 28 commits May 15, 2026 13:07
…CVE-2022-38900)

- Update decode-uri-component from 0.2.0 to 0.2.2 via package-lock.json
- This patch version update fixes the improper input validation vulnerability
- No code changes required in the application
- Vulnerability resolved: CVE-2022-38900 (CVSS 7.5)
Adds 'secure: true' to the express-session cookie configuration to ensure
session cookies are only transmitted over HTTPS connections. This prevents
session hijacking via man-in-the-middle attacks on HTTP connections.

Fixes: javascript.express.security.audit.express-cookie-settings.express-cookie-session-no-secure
…4-29041

fix: express: cause malformed URLs to be evaluated
…2021-23358

fix: nodejs-underscore: Arbitrary code execution via the template function
…alidation

fix: Prevent open redirect vulnerability in /learn endpoint
…2019-10746

fix: nodejs-mixin-deep: prototype pollution in function mixin-deep


fix: bson: Deserialization of Untrusted Data vulnerability CVE-2020-7610
…019-10747

fix: nodejs-set-value: prototype pollution in function set-value
…ponent-cve-2022-38900

fix: decode-uri-component: improper input validation resulting in DoS
…n-secure

fix: Add secure flag to session middleware cookie configuration
Bump minimist from 1.2.0 to 1.2.8 via npm overrides to fix CVE-2021-44906

The minimist package is vulnerable to prototype pollution in versions <=1.2.5.
This patch updates minimist to 1.2.8 which includes the fix for this critical
vulnerability (CVSS 9.8). The update is applied via npm overrides to ensure
all transitive dependencies use the patched version.
…20165)

- Added explicit debug@^3.1.0 dependency to override transitive dependencies pinning debug@2.2.0
- This addresses the ReDoS vulnerability in the useColors function identified in CVE-2017-20165
- The 3.1.0 version provides a safe regex pattern without breaking changes
- Regenerated package-lock.json to reflect the new dependency constraints
…VE-2022-21681

This commit patches the Regular Expression Denial of Service (ReDoS) vulnerability in marked's inline.reflinkSearch regex pattern (CVE-2022-21681).

Changes:
- Upgraded marked dependency from 0.3.5 to 4.0.10
- Removed deprecated sanitize option from marked.setOptions() call
- Updated package-lock.json with new dependency versions

The vulnerability allowed catastrophic backtracking against certain markdown patterns, potentially leading to DoS. Version 4.0.10 includes the fix.

Note: The sanitize option is no longer available in marked@4.x. HTML sanitization is no longer built-in. Consider using DOMPurify or similar on the frontend for additional security if displaying user-generated markdown.
- Add template path validation to prevent directory traversal attacks
- Restrict include/extends tags to files within app/views directory
- Document upstream vulnerability (swig@1.4.2 has no patched version available)
- Implement interim mitigation until migration to maintained template engine

Fixes CVE-2023-25345: Arbitrary local file read via template includes/extends
Related: https://nvd.nist.gov/vuln/detail/CVE-2023-25345
…21681

fix: upgrade marked from 0.3.5 to 4.0.10 to fix ReDoS vulnerability CVE-2022-21681
…2017-20165

fix: upgrade debug to 3.1.0 to address ReDoS vulnerability (CVE-2017-20165)
- Removed artifacts/cert/server.key from entire git history using BFG Repo-Cleaner
- Updated .gitignore to prevent future commits of certificate/key files
- All 938 affected objects rewritten to remove private key material
- Private key no longer accessible via git history
Comment on lines +6 to +61
name: Node.js
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: ["10.x", "12.x", "14.x"]

steps:
- name: Checkout https://github.com/${{ github.repository }}@${{ github.ref }}
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Use cache
uses: actions/cache@v2
with:
path: |
~/.npm
~/.cache
key: ${{ runner.os }}-node${{ matrix.node-version }}-E2E-${{ hashFiles('package-lock.json') }}

- name: Install dependencies
run: |
npm ci
npm run cy:verify

- name: Start MongoDB
run: |
docker run -d -p 27017:27017 mongo:4.0
timeout 60s bash -c 'until nc -z -w 2 localhost 27017 && echo MongoDB ready; do sleep 2; done'

- name: Run E2E test suite
id: test-suite
run: |
NODE_ENV=test npm start -- --silent &
npm run test:ci -- --config video=true

- name: Prepare cypress artifacts
if: failure() && (steps.test-suite.outcome == 'failure')
working-directory: ./test/e2e
run: >
mkdir -p "screenshots" && find "screenshots" -mindepth 1 -maxdepth 1 -type d
-exec sh -c 'mv -- "videos/$(basename "$1").mp4" "$1"' _ {} \;

- name: Upload cypress artifacts
if: failure() && (steps.test-suite.outcome == 'failure')
uses: actions/upload-artifact@v2
with:
name: cypress-artifacts-node${{ matrix.node-version }}
path: test/e2e/screenshots
Comment on lines +6 to +26
name: Node.js
runs-on: ubuntu-latest

strategy:
fail-fast: false
matrix:
node-version: ["14.x"]

steps:
- name: Checkout https://github.com/${{ github.repository }}@${{ github.ref }}
uses: actions/checkout@v2
with:
persist-credentials: false

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}

- name: Run linter
run: npx --no-install jshint@2.12.0 .
throw `The user supplied threshold: ${parsedThreshold} was not valid.`;
*/
return {
$where: `this.userId == ${parsedUserId} && this.stocks > '${threshold}'`
Comment thread app/data/user-dao.js
Comment on lines +91 to +93
usersCol.findOne({
userName: userName
}, validateUserDoc);
Comment thread app/data/user-dao.js
Comment on lines +104 to +106
usersCol.findOne({
userName: userName
}, callback);

/*jslint evil: true */
// Insecure use of eval() to parse inputs
const preTax = eval(req.body.preTax);
/*jslint evil: true */
// Insecure use of eval() to parse inputs
const preTax = eval(req.body.preTax);
const afterTax = eval(req.body.afterTax);
Comment thread app/routes/profile.js
// const regexPattern = /([0-9]+)\#/;
const regexPattern = /([0-9]+)+\#/;
// Allow only numbers with a suffix of the letter #, for example: 'XXXXXX#'
const testComplyWithRequirements = regexPattern.test(bankRouting);
Comment thread app/routes/research.js
Comment on lines +16 to +28
return needle.get(url, (error, newResponse, body) => {
if (!error && newResponse.statusCode === 200) {
res.writeHead(200, {
"Content-Type": "text/html"
});
}
res.write("<h1>The following is the stock information you requested.</h1>\n\n");
res.write("\n\n");
if (body) {
res.write(body);
}
return res.end();
});
Comment thread app/routes/session.js
return false;
}
if (email !== "") {
if (!EMAIL_RE.test(email)) {
Comment thread server.js
Comment on lines +78 to +100
app.use(session({
// genid: (req) => {
// return genuuid() // use UUIDs for session IDs
//},
secret: cookieSecret,
// Both mandatory in Express v4
saveUninitialized: true,
resave: true,
/*
// Fix for A5 - Security MisConfig
// Use generic cookie name
key: "sessionId",
*/

// Fix for A3 - XSS and session hijacking prevention
// TODO: Add "maxAge"
cookie: {
httpOnly: true,
// Remember to start an HTTPS server to get this working
secure: true
}

}));
Comment thread app/utils/urlValidator.js
}

// Safe to redirect
return res.redirect(validation.url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.