被污染的数据缺陷
与来自不安全来源的代码元素相关的缺陷
被污染的数据缺陷用来标记在某些运算中使用了被污染的数据。来自不安全来源的数据是被污染的数据。Polyspace® 认为以下来源不安全:
易失对象。
使用标准库函数获取的外部输入。外部输入可能包括:
用户输入
环境变量
文件内容或文件路径
从硬件获取的数据
在使用数据之前,请验证从这类不安全来源获取的被污染数据。恶意攻击者可能会使用未经验证的被污染数据攻击您的程序并造成故障。被污染的数据缺陷用来标记在某些运算中使用了未经验证的被污染数据。例如,Polyspace 会标记:
各个数值运算中的被污染数据。
在外部控制的元素,例如路径、命令、环境变量和主机 ID。
内存操作(例如分配和取消引用)中的被污染数据。
Polyspace 结果
使用被污染的索引进行数组访问 | 来自不安全源的数组索引可能超出数组范围 |
从外部控制路径执行的命令 | Path argument from an unsecure source |
执行外部控制命令 | Command argument from an unsecure source vulnerable to operating system command injection |
使用外部控制元素进行主机更改 | Changing host ID from an unsecure source |
从外部控制路径加载的库 | Using a library argument from an externally controlled path |
循环界限值被污染 | Loop controlled by a value from an unsecure source |
内存分配大小被污染 | Size argument to memory function is from an unsecure source |
使用被污染的偏移量进行指针解引用 | Offset is from an unsecure source and dereference might be out of bounds |
除法操作数被污染 | Operands of division operation (/ ) come from an unsecure
source |
模操作数被污染 | Operands of remainder operation (% ) come from an unsecure
source |
被污染的 NULL 或不以 null 结尾的字符串 | Argument is from an unsecure source and might be NULL or not NULL-terminated |
符号变化转换被污染 | Value from an unsecure source changes sign |
可变长度数组大小被污染 | Size of the variable-length array (VLA) is from an unsecure source and might be zero, negative, or too large |
敏感函数使用了污染源 | Data obtained from an untrusted source is passed to user-defined sensitive function (自 R2023b 起) |
字符串格式被污染 | Input format argument is from an unsecure source |
使用外部控制的环境变量 | Value of environment variable is from an unsecure source |
使用被污染的指针 | Pointer from an unsecure source may be NULL or point to unknown memory |
主题
- Sources of Tainting in a Polyspace Analysis
Validate tainted data obtained from external sources to avoid security risks.
- Bug Finder 缺陷组
Bug Finder 的缺陷检查项分为数据流、并发、数值等分组。