CWE-843 使用不兼容类型访问资源(类型混淆) 类弱点 348 条 CVE 漏洞汇总,含 AI 中文分析。
CWE-843类型混淆漏洞指程序以不兼容类型访问已分配资源,导致逻辑错误。攻击者常利用此缺陷操纵内存布局,引发数据泄露或代码执行。开发者应严格实施类型检查,确保变量声明与使用类型一致,并在C等无内存安全语言中引入静态分析工具,从源头杜绝类型不匹配风险,保障系统稳定性。
#define NAME_TYPE 1 #define ID_TYPE 2 struct MessageBuffer { int msgType; union { char *name; int nameID; }; }; int main (int argc, char **argv) { struct MessageBuffer buf; char *defaultMessage = "Hello World"; buf.msgType = NAME_TYPE; buf.name = defaultMessage; printf("Pointer of buf.name is %p\n", buf.name); /* This particular value for nameID is used to make the code architecture-independent. If coming from untrusted input, it could be any value. */ buf.nameID = (int)(defaultMessage + 1); printf("Pointer of buf.name is now %p\n", buf.name); if (buf.msgType == NAME_TYPE) { printf("Message: %$value = $_GET['value']; $sum = $value + 5; echo "value parameter is '$value'<p>"; echo "SUM is $sum";CWE-843(使用不兼容类型访问资源(类型混淆)) 是常见的弱点类别,本平台收录该类弱点关联的 348 条 CVE 漏洞。