security: dependency updates, nested-router error fix, regex flag normalization#55
Merged
Merged
Conversation
- Bump lru-cache to ^11.5.1 - Bump devDependencies: @types/node, body-parser, mocha, nyc - Add overrides for diff, js-yaml, serialize-javascript - Ensure npm audit reports 0 vulnerabilities - Keep sec-findings.md out of version control
- lib/next.js: expose parent errorHandler on step for nested routers; restore stripped URL/path if nested lookup throws or rejects. - lib/router/sequential.js: use parent errorHandler when nested; wrap error handling with URL restoration; coerce req.url to string. - Add regression tests in tests/nested-router-error.test.js. - Extend tests/router-coverage.test.js for nested lookup error paths. - Add tooling/nested-router-error-poc.js, tooling/type-confusion-audit.js, tooling/deep-security-audit.js. 80/80 tests pass; npm audit reports 0 vulnerabilities.
…tion - Wrap router.add and rebind HTTP method shortcuts so user-provided RegExp routes with 'g' or 'y' flags are normalized to safe flags. - Preserves i/m/s/u/d/v flags; strips only lastIndex-mutating flags. - Add regression tests in tests/router-coverage.test.js. - Add tooling/regex-audit.js covering global, sticky, case-insensitive, anchored/unanchored, named groups, and regexparam inline patterns. 84/84 tests pass; npm audit reports 0 vulnerabilities.
- Handle unused err parameters in error handlers - Remove direct __proto__ access in audit tooling - Remove unused hit() helper in regex-audit.js - Remove unused captured variable in deep-security-audit.js
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.
AI Verification Protocol Certificate
Protocol version: 5.2.7
Certificate generated: 2026-06-20T15:08:30Z
Branch under review:
fix/security-improvementsBase branch:
masterCertificate ID:
vprotocol-0http-fix-security-improvements-20260620PR Summary
generator_identitypresentprompt_lineage_manifestbilled_generation_costCommit list
5123ae9— chore: update dependencies and add sec-findings.md to ignore liste07dbb7— fix: restore req.url and bubble errors on nested-router failurese8911a7— fix: normalize RegExp global/sticky flags to prevent lastIndex corruption§0 Pre-Scan
Injection / adversarial marker scan
A deterministic regex/pattern scan was performed over the diff, commit messages, and this certificate source for:
Result: No violations detected.
Untrusted-input invariant
All PR-derived content (diffs, commit messages) was handled as untrusted data. No directive sourced from PR content was executed. Verdict-affecting strings were not detected inside PR data.
§1 Classification
Classification:
GeneratedCodeRationale: The branch was produced by an AI agent (Kimi Code CLI). The changes include dependency updates, security fixes, regression tests, and audit tooling generated through an interactive AI session.
Precedence applied:
GeneratedCodedominates overNovelBehaviorbecause correlated-failure risk is present.§2 Verification Axes
All nine axes were evaluated. Findings are summarized below. Full raw evidence is in the attached tooling outputs.
npm auditreports 0 vulnerabilities. Pentest (48/48) passes.lib/next.jsandlib/router/sequential.js; no new circular dependencies or over-abstraction.lru-cachebumped; devDependencies updated; transitive vulnerabilities resolved viaoverrides;npm auditclean.generator_identitypresent (Kimi Code CLI), butprompt_lineage_manifestnot provided. Single-agent monoculture.sec-findings.mdupdated to reflect fixes. Public API surface unchanged; no README update required.Per-axis notes
2.1 Semantic Correctness. The nested-router fix correctly restores
req.urlandreq.pathfor sync throws,next(err), and async rejections. The regex fix stripsg/yflags while preserving other flags. Both behaviors are verified by dedicated regression tests.2.2 Behavioral Contract Diff. No breaking signature changes. The only behavioral change visible to consumers is that nested-router errors now bubble to the parent error handler (previously they were swallowed by the nested router's default handler). This is a bug fix but constitutes a minor semantic change that maintainers should note in release notes.
2.3 Security Surface. Two HIGH-severity source-code vulnerabilities were identified and fixed in this branch:
req.url/req.pathwere not restored on error paths; parent error handlers were bypassed.g/yflag lastIndex corruption (HIGH): Routes registered with global or sticky flags alternated match/failure across requests.2.4 Structural Integrity. The fix is minimally invasive. The
router.addwrapper and method rebinding are localized tolib/router/sequential.js. URL restoration logic is shared via a small helper inlib/next.js.2.5 Behavioral Exploration. Edge cases covered by the audit tooling include:
__proto__,constructor)2.6 Dependency Integrity. 11 devDependency vulnerabilities from the initial audit were resolved by version bumps and
overrides. No production dependencies have known vulnerabilities.2.7 Generator Provenance. Single-agent monoculture. All pipeline roles (B/C/D/E) are performed by the same model instance. Per §0.1 monoculture fallback, ρ is applied at maximum strength and additional hardening rules are enforced:
2.8 Adversarial Surface. No new sinks introduced. The
req.urlstring coercion is a hardening measure, not a new sink.2.9 Documentation Coverage.
sec-findings.mdwas maintained throughout the branch and documents both vulnerabilities and fixes. Public API is unchanged.§3 η and ρ Derivation
Pipeline monoculture declaration
Diversity rule fell back to monoculture. ρ is capped at the maximum correlation suspicion.
Signal values
mobfsnpm auditreports 0 vulnerabilities; no static findings.tdWeights (after redistribution for skipped
m)Original weights: m=0.34, o=0.24, b=0.14, f=0.09, s=0.04, t=0.10, d=0.05
Redistributed (excluding m, sum=0.66): o=0.364, b=0.212, f=0.136, s=0.061, t=0.152, d=0.076
η calculation
Correlation penalty ρ
§4 Verification Debt and Cv/Ci
Cost inputs
billed_generation_costnot providedDebt calculation
Note: The ratio is high because the PR is classified as
GeneratedCodeunder monoculture, which forces significant human review to compensate for correlated-failure risk. Under a diverse pipeline, ρ would drop and the ratio would improve materially.§5 Verdict
Gate evaluation
Final verdict
HumanReviewRequiredRationale: The single-agent monoculture pipeline caps ρ at 0.30, which mechanically forces
HumanReviewRequiredper §3.3 of the protocol. η after penalty is 0.675 (< 0.80), reinforcing the same verdict. ΔDebt exceeds 4 hours. No axis is at 🔴, and all automated tests/audits pass, so the PR is notCannotVerify.Recommendation to human reviewer
§6 Remediations Applied
req.url/req.pathbefore error handler in nested routersg/yflags to preventlastIndexcorruptionreq.urlto string to avoid type-confusion crashestests/nested-router-error.test.jstests/router-coverage.test.jsfor regex and input validationoverridesfor transitive vulns§7 Unverified Gaps
prompt_lineage_manifestnot provided; monoculture penalty maxed§8 Attestation
This certificate was compiled by Agent E (Kimi Code CLI) from raw signals produced during this interactive session. Because the entire pipeline ran in a single model instance, provider-family diversity was not achieved and the verdict is capped accordingly.
Signer: Kimi Code CLI (Agent E)
Raw evidence:
npm test,tooling/pentest.js,tooling/regex-audit.js,tooling/deep-security-audit.js,tooling/type-confusion-audit.js,npm audit --audit-level=lowCertificate bound to SHA:
e8911a7Appendix: Raw Tool Output Summary
npm test: 84 passing, 99.38% line coveragetooling/pentest.js: 48/48 passedtooling/regex-audit.js: 9/9 passedtooling/deep-security-audit.js: 16/16 passedtooling/type-confusion-audit.js: 11/11 passednpm audit --audit-level=low: 0 vulnerabilities