Authorization disclaimer. This walkthrough is limited to the intentionally vulnerable PortSwigger Web Security Academy lab linked below. Test only systems you own or are explicitly authorized to assess.
Overview
The XML stock API evaluates storeId as SQL while its filter examines a different representation: storeId=1+2 is evaluated; raw UNION is blocked as Attack detected, but Hackvertor XML hex entities decode before the database and allow UNION SELECT username||’:’||password FROM users –. Entity decoding restores the blocked UNION after inspection.
Lab objective/setup
Exercise SQL injection with filter bypass via XML encoding through the endpoint and input recorded in the lab note. storeId=1+2 is evaluated; raw UNION is blocked as Attack detected, but Hackvertor XML hex entities decode before the database and allow UNION SELECT username||':'||password FROM users --.
What I observed
storeId=1+2 is evaluated; raw UNION is blocked as Attack detected, but Hackvertor XML hex entities decode before the database and allow UNION SELECT username||':'||password FROM users --.



Why it is vulnerable
storeId=1+2 is evaluated; raw UNION is blocked as Attack detected, but Hackvertor XML hex entities decode before the database and allow UNION SELECT username||':'||password FROM users --. The application passes that value into the security-sensitive operation without the context-specific validation or encoding needed to prevent this result.
Walkthrough in the authorized PortSwigger lab
Prove expression evaluation with storeId=1+2, observe that a raw UNION triggers Attack detected, then encode the UNION payload as XML hex entities before submitting it in the stock body. Read the concatenated user credentials from the decoded query result.




Verification
The lab is confirmed when storeId=1+2 is evaluated; raw UNION is blocked as Attack detected, but Hackvertor XML hex entities decode before the database and allow UNION SELECT username||':'||password FROM users --. The captured result and the Academy solved state provide the verification; an ordinary status code alone does not.
Impact and defensive lesson
Canonicalization gaps let encoded SQL pass a signature filter. Parse and normalize once, validate the normalized value, and still use a parameterized query; a WAF must not be the data layer’s only defense.