CWE-464: Addition of Data Structure Sentinel
CWE版本: 4.18
更新日期: 2025-09-09
弱点描述
The accidental addition of a data-structure sentinel can cause serious programming logic problems.
扩展描述
Data-structure sentinels are often used to mark the structure of data. A common example of this is the null character at the end of strings or a special sentinel to mark the end of a linked list. It is dangerous to allow this type of control data to be easily accessible. Therefore, it is important to protect from the addition or modification of sentinels.
常见后果
影响范围: Integrity
技术影响: Modify Application Data
说明: Generally this error will cause the data structure to not work properly by truncating the data.
潜在缓解措施
阶段: Implementation Architecture and Design
描述: Encapsulate the user from interacting with data sentinels. Validate user input to verify that sentinels are not present.
阶段: Implementation
描述: Proper error checking can reduce the risk of inadvertently introducing sentinel values into data. For example, if a parsing function fails or encounters an error, it might return a value that is the same as the sentinel.
阶段: Architecture and Design
描述: Use an abstraction library to abstract away risky APIs. This is not a complete solution.
阶段: Operation
描述: Use OS-level preventative functionality. This is not a complete solution.
引入模式
| 阶段 | 说明 |
|---|---|
| Implementation | - |
适用平台
编程语言
分类映射
| 分类名称 | 条目ID | 条目名称 | 映射适配度 |
|---|---|---|---|
| CLASP | - | Addition of data-structure sentinel | - |
| CERT C Secure Coding | STR03-C | Do not inadvertently truncate a null-terminated byte string | - |
| CERT C Secure Coding | STR06-C | Do not assume that strtok() leaves the parse string unchanged | - |