security: round 3 hardening (CSRF double-submit, TRX MITM, container hardening)
This commit is contained in:
@@ -111,7 +111,8 @@ async function getFeeEstimates(_req: Request, res: Response) {
|
||||
async function broadcastTx(req: Request, res: Response) {
|
||||
const { hex } = req.body;
|
||||
|
||||
if (!hex || typeof hex !== 'string' || !/^[0-9a-fA-F]+$/.test(hex)) {
|
||||
// BTC max tx serialized ~100KB = 200_000 hex chars. Cap чтобы не abuse'или bandwidth.
|
||||
if (!hex || typeof hex !== 'string' || !/^[0-9a-fA-F]+$/.test(hex) || hex.length > 200_000) {
|
||||
res.status(400).json({ success: false, error: 'Invalid transaction hex' });
|
||||
return;
|
||||
}
|
||||
@@ -130,7 +131,8 @@ async function broadcastTx(req: Request, res: Response) {
|
||||
const text = await response.text();
|
||||
|
||||
if (!response.ok) {
|
||||
res.status(response.status).json({ success: false, error: text || 'Broadcast failed' });
|
||||
// Don't leak Blockstream error body (could contain UTXO state oracle).
|
||||
res.status(502).json({ success: false, error: 'BTC broadcast failed' });
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user