Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

GOLD-238 fix: sql injection when recordTxStatus feature is on #59

Merged
merged 1 commit into from
Sep 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ export const CONFIG: Config = {
},
aalgWarmup: false,
aalgWarmupServiceTPS: 10,
recordTxStatus: false,
recordTxStatus: false, // not safe for production, keep this off. Known issue.
rateLimit: false,
rateLimitOption: {
softReject: true,
Expand All @@ -158,7 +158,7 @@ export const CONFIG: Config = {
releaseFromBlacklistInterval: 12, // remove banned ip from blacklist after 12 hours
allowedHeavyRequestPerMin: 20, // number of eth_call + tx inject allowed within 60s
},
statLog: false,
statLog: false, // not safe for production, keep this off
passphrase: process.env.PASSPHRASE || 'sha4d3um', // this is to protect debug routes
secret_key: process.env.SECRET_KEY || 'YsDGSMYHkSBMGD6B4EmD?mFTWG2Wka-Z9b!Jc/CLkrM8eLsBe5abBaTSGeq?6g?P', // this is the private key that rpc server will used to sign jwt token
adaptiveRejection: true,
Expand Down
8 changes: 7 additions & 1 deletion src/middlewares/injectIP.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@ import { CONFIG } from '../config'
import { NextFunction, Request, Response } from 'express'

const injectIP = (req: Request, res: Response, next: NextFunction): void => {
if (req.body.method === 'eth_sendRawTransaction' && CONFIG.recordTxStatus) req.body.params[1000] = req.ip
if (req.body.method === 'eth_sendRawTransaction' && CONFIG.recordTxStatus){
const regex_str = /^(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])(\.(25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]?[0-9])){3}$/;
const regex = new RegExp(regex_str)
if (regex.test(req.ip)){
req.body.ip = req.ip
}
}
next()
return
}
Expand Down
Loading