Install any skill in seconds. Free to start, no credit card required.
Get Started Free →Checks payment callback and webhook handlers for forged requests, replay attacks, and amount tampering.
91% 100%+9 ptsof test cases passed
Passed 22 of 22 test cases with the skill, and 20 of 22 without it.
请帮我审查这段微信支付 API v3 的回调处理代码。在公网暴露回调端点时,我担心可能存在安全性或者并发重复调用的隐患。请检查代码中的漏洞,并给出符合安全规范的重构后 Java 代码与修补说明。
Validates that callback total amount matches the expected local order amount.
3 of 3 safety checks passed
当系统涉及第三方支付回调(微信支付、支付宝等)或 webhook 通知时,防止伪造、篡改和重放攻击。
场景: 收到支付回调后直接解密/解析并处理,未验证请求确实来自支付平台
支付回调地址暴露在公网,任何人都可以伪造请求。如果不验签,攻击者可以构造假的"支付成功"通知。
// ❌ 错误: 直接解密处理,未验签
@PostMapping("/payment/callback/wechat")
public String wechatCallback(@RequestBody String body) {
JsonNode json = objectMapper.readTree(body);
// 直接尝试解密 resource
String decrypted = decryptAesGcm(ciphertext, apiV3Key, nonce, aad);
processPayment(decrypted); // 谁发来的都处理
return "{\"code\":\"SUCCESS\"}";
}
// ✅ 正确: 先验签,再解密,再处理
@PostMapping("/payment/callback/wechat")
public String wechatCallback(
@RequestBody String body,
@RequestHeader("Wechatpay-Signature") String signature,
@RequestHeader("Wechatpay-Timestamp") String timestamp,
@RequestHeader("Wechatpay-Nonce") String nonce,
@RequestHeader("Wechatpay-Serial") String serial) {
Published skills whose descriptions closely match this one, with their benchmark result.
Next to this one in the catalogue, plus more from the same author.