Fix security vulnerabilities in Node.js driver#2329
Merged
MuhammadTahaNaveed merged 1 commit intoapache:masterfrom Feb 13, 2026
Merged
Fix security vulnerabilities in Node.js driver#2329MuhammadTahaNaveed merged 1 commit intoapache:masterfrom
MuhammadTahaNaveed merged 1 commit intoapache:masterfrom
Conversation
6bc32a4 to
b1c8379
Compare
There was a problem hiding this comment.
Pull request overview
This PR hardens the Node.js AGE driver against SQL injection and correctness issues by adding identifier validation, safer Cypher execution helpers, and improved agtype parsing behavior for large integers.
Changes:
- Added validation helpers for graph/label/column identifiers and introduced safer query wrappers (
queryCypher,createGraph,dropGraph). - Updated agtype integer parsing to use
BigIntwhen values exceedNumber.MAX_SAFE_INTEGER. - Adjusted driver behavior/tests:
setAGETypesno longer auto-runsCREATE EXTENSIONby default, updated tests andpgdependency floor.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| drivers/nodejs/package.json | Tightens pg dependency to >=8.0.0. |
| drivers/nodejs/src/antlr4/CustomAgTypeListener.ts | Parses large integers as BigInt to avoid precision loss. |
| drivers/nodejs/src/index.ts | Adds validation + safe query helpers; makes CREATE EXTENSION opt-in; improves missing agtype error message. |
| drivers/nodejs/test/Agtype.test.ts | Adds coverage for BigInt vs number parsing behavior. |
| drivers/nodejs/test/index.test.ts | Adds validation/injection-prevention tests and exercises new helper APIs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
b1c8379 to
8c815ac
Compare
Fix security vulnerabilities in Node.js driver and harden input
validation and query construction.
Note: This PR was created with AI tools and a human.
- Add input validation for graph names, label names, and column names
to prevent SQL injection via string interpolation. Graph name rules
are based on Apache AGE's naming conventions and Neo4j/openCypher
compatibility (hyphens and dots permitted, min 3 chars, max 63 chars).
Label names follow AGE's stricter rules (no hyphens or dots).
- Add design documentation noting intentional ASCII-only restriction
in driver-side regex validation as a security hardening measure
(homoglyph/encoding attack surface reduction). AGE's server-side
validation (name_validation.h) uses full Unicode ID_Start/ID_Continue
and remains the authoritative check for Unicode names.
- Add safe query helpers: queryCypher(), createGraph(), dropGraph()
with graph name validation and dollar-quoting for Cypher strings
- Add runtime typeof check on dropGraph cascade parameter to prevent
injection from plain JavaScript consumers (TypeScript types are
erased at runtime)
- Use BigInt for integer values exceeding Number.MAX_SAFE_INTEGER to
prevent silent precision loss with 64-bit AGE graph IDs
- Make CREATE EXTENSION opt-in via SetAGETypesOptions.createExtension
instead of running DDL automatically without user consent
- Wrap LOAD/search_path setup in try/catch with actionable error
message mentioning CREATE EXTENSION and { createExtension: true }
- Improve agtype-not-found error message with installation guidance
- Tighten pg dependency from >=6.0.0 to >=8.0.0
- Add comprehensive test suites covering validation, SQL injection
prevention, cascade type safety, hyphenated graph name integration,
BigInt parsing, and setAGETypes error handling
- Add design note in tests documenting why createExtension: false is
the correct default (CI image has AGE pre-installed, auto-creating
extensions requires SUPERUSER and conflates concerns)
modified: drivers/nodejs/package.json
modified: drivers/nodejs/src/antlr4/CustomAgTypeListener.ts
modified: drivers/nodejs/src/index.ts
modified: drivers/nodejs/test/Agtype.test.ts
modified: drivers/nodejs/test/index.test.ts
8c815ac to
515c533
Compare
MuhammadTahaNaveed
approved these changes
Feb 13, 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.
Note: This PR was created with AI tools and a human.
All existing regression tests passed.
modified: drivers/nodejs/package.json
modified: drivers/nodejs/src/antlr4/CustomAgTypeListener.ts
modified: drivers/nodejs/src/index.ts
modified: drivers/nodejs/test/Agtype.test.ts
modified: drivers/nodejs/test/index.test.ts