Skip to content

Commit f4ea32e

Browse files
Add txid validation to elements_getunblindedurl
Security fix: Validate txid parameter before processing to prevent potential injection or malformed input issues. - Checks txid is not empty - Validates txid is exactly 64 hexadecimal characters - Returns proper error JSON if validation fails Code review fix for PR #360
1 parent 31376a7 commit f4ea32e

1 file changed

Lines changed: 11 additions & 0 deletions

File tree

proxy_docker/app/script/elements_blockchainrpc.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -189,6 +189,17 @@ elements_getunblindedurl() {
189189

190190
local txid=${1}
191191
trace "[elements_getunblindedurl] txid=${txid}"
192+
193+
# Validate txid format (64 hex characters)
194+
if [ -z "${txid}" ]; then
195+
echo "{\"error\":\"txid is required\"}"
196+
return 1
197+
fi
198+
if ! echo "${txid}" | grep -qE '^[a-fA-F0-9]{64}$'; then
199+
echo "{\"error\":\"Invalid txid format\"}"
200+
return 1
201+
fi
202+
192203
local base_url=${2:-"https://liquid.network"}
193204
trace "[elements_getunblindedurl] base_url=${base_url}"
194205

0 commit comments

Comments
 (0)