# Unchecked Return Value (CWE-252) The product does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions. **Stack:** Go - Prevalence: 中 覆盖 2 种语言 - Impact: 高 1 条严重级别为高的规则 - Prevention: 已记录 2 个修复示例 **OWASP:** Insecure Design (A04:2021-Insecure Design) - #4 ## Description When return values are not checked, the program may continue execution in an error state or with incorrect data, potentially leading to security vulnerabilities. ## Prevention 基于 1 条 Shoulder 检测规则的 Unchecked Return Value 预防策略。 ### Go Replace blank identifier _ with err and check error return values ## Consequences - 拒绝服务 (DoS) - 执行未授权代码 - 修改应用程序数据 ## Mitigations - 始终检查函数的返回值 - 使用编译器警告检测未检查的返回值 - 适当地处理错误情况 ## Detection - Total rules: 2 - Languages: go, javascript, typescript ## Rules by Language ### Go (1 rules) - **Unchecked Error Return Values** [MEDIUM]: Error return value ignored using blank identifier (_). - Remediation: Check all error return values and handle appropriately. ```go data, err := ioutil.ReadFile(path) if err != nil { return fmt.Errorf("failed to read file: %w", err) } ``` Learn more: https://shoulder.dev/learn/go/cwe-252/unchecked-errors