识别漏洞成了大海捞针?
识别漏洞成了大海捞针?
原创 做安全的小明同学 大山子雪人 2025-01-13 11:04
2025.1月份的android公告,最大的变化就是少了漏洞对应patch的链接
没有了patch,就没法分析漏洞的成因,也就无从学起。也不知道漏洞什么时候修复的,什么时候commit到aosp的。头大,简直大海捞针。
由于不知道时间范围,只能挨个commit爬了
commit收集入口:
https://android.googlesource.com/platform/frameworks/base/+log?format=JSON
拿到commitid后,经过拼接就可以得到patch url
https://android.googlesource.com/platform/frameworks/base/+/1a1f9bf4315168629cb78206cd0211edbac9dd8a%5e%21?format=TEXT
这样就可以拿到patch了。
接下来就是对patch的智能分析。这时就可以祭出大模型了。
chat_completion = client.chat.completions.create( messages=[ { "role": "user", "content": f"{prompt}", } ], model="gpt-4o",)
结果如下:
提取下图片中的重点:
patch部分:
} else { p.mTitle = getString(com.android.internal.R.string.ringtone_picker_title);}+ } else {+ // Make sure intents don't inject HTML elements.+ p.mTitle = Html.escapeHtml(p.mTitle.toString());}
chatgpt对patch的分析:
- Context of Change:
The code diff indicates the addition of a line that uses Html.escapeHtml()
on the variable p.mTitle
.
- Purpose of
Html.escapeHtml()
:
– This method converts special HTML characters to their respective HTML entities.
– It effectively prevents HTML tags from being embedded in strings when they are displayed in a UI, which can prevent potential HTML/JavaScript injection attacks.
- Resolved Vulnerability:
– The original code did not sanitize the p.mTitle
input for HTML content, potentially allowing an attacker to inject arbitrary HTML or script content if they controlled the data source for this variable.
– By introducing Html.escapeHtml(p.mTitle.toString())
, this threat is mitigated by removing any executable HTML/script content and converting it to a safe, displayable format.
chatgpt对patch的总结:
Conclusively, the addition made in the code is a positive security enhancement and addresses a significant potential vulnerability of HTML/script injection.