Repository navigation
fix(security): prevent SQL injection in PostgresClient (CWE-89) and harden sync-rpc (CWE-78, CWE-668) - #753
Closed
thinhnx128 wants to merge 1 commit into
Conversation
Author
|
I have read the Arakoo CLA Document and I hereby sign the CLA |
…ync-rpc execution (CWE-78)
thinhnx128
force-pushed
the
fix/security-sql-injection-command-injection-cwe89-cwe78
branch
from
October 31, 2026 05:06
ff0010a to
0683ddc
Compare
Author
|
Closing this to reduce review load — it wasn't requested by the maintainers. Thanks for your time; happy to reopen if it's useful. |
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Defensive Security Summary
This PR resolves three defensive security vulnerabilities identified during our static security audit of
arakoodev/EdgeChains:1. SQL Injection Prevention in
PostgresClient.dbQuery()(CWE-89)JS/edgechains/arakoodev/src/db/src/lib/postgres-client/PostgresClient.tsinterpolatedthis.arkRequest.query,this.namespace,this.tableName,this.arkRequest.metadataTable, and numeric RRF weights directly into raw SQL strings.escapeSqlLiteral()(doubling single quotes and stripping null bytes),validateSqlIdentifier()(^[A-Za-z_][A-Za-z0-9_]{0,62}$), andsanitizeNumber()while preserving the exact single-stringentityManager.query(query)call signature for backward compatibility.postgresClient.test.tsverifying quote escaping and invalid identifier rejection.2. Shell Command Injection & Double-Unlink Hardening in
sync-rpc.ts(CWE-78)JS/edgechains/arakoodev/src/sync-rpc/lib/sync-rpc.tsinvokedexecSync(\node ${scriptPath}`)via a shell (which breaks on temporary directories containing spaces or special characters) and calledfs.unlinkSync(scriptPath)twice whenJSON.parse` failed.execSyncwithexecFileSync(process.execPath, [scriptPath])(no shell interpolation) and moved temporary script cleanup into afinallyblock guarded byfs.existsSync(scriptPath).3. Loopback-Only Binding in
JS/wasm/sync-rpc/worker.js(CWE-668)server.listen(process.argv[2])bound the unauthenticatedsync-rpcTCP worker (which dynamicallyrequire()s modules) to all network interfaces (0.0.0.0/::).127.0.0.1) matching the client host.