西西河

主题:【原创】Chrome程序初探(序) -- 素里太守

共:💬73 🌺137 新:
全看分页树展 · 主题 跟帖
家园 一点小花絮,“:%” 虫

Chrome推出后,网友们很快就发现了崩溃它的“秘诀” --- :%。

于是有人说:

也许,这本身就是一个彩蛋,Google Chrome开发人员的一个玩笑,要让Chrome崩溃如此简单。

不过真实的情况是,这是一个虫,正二八经的虫。

出错的代码位于c:\chrome\src\net\base\escape.cc,错误犯的还比较低级。

std::string UnescapeURLImpl(const std::string& escaped_text,

UnescapeRule::Type rules) {

// The output of the unescaping is always smaller than the input, so we can

// reserve the input size to make sure we have enough buffer and don't have

// to allocate in the loop below.

std::string result;

result.reserve(escaped_text.length());

for (size_t i = 0, max = escaped_text.size(), max_digit_index = max - 2;

i < max; ++i) {

if (escaped_text[i] == '%' && i < max_digit_index) {

const std::string::value_type most_sig_digit(escaped_text[i + 1]);

const std::string::value_type least_sig_digit(escaped_text[i + 2]);

if (IsHex(most_sig_digit) && IsHex(least_sig_digit)) {

unsigned char value = HexToInt(most_sig_digit) * 16 +

HexToInt(least_sig_digit);

当escaped_text的长度为1,而且仅包含%字符时“可能”出现非法访问的问题。

俺把代码改了一下

unsigned char textplusplus = ((i + 1) < max)?escaped_text[i + 2]:escaped_text[i + 1];

const std::string::value_type most_sig_digit(escaped_text[i + 1]);

const std::string::value_type least_sig_digit(textplusplus);

编译链接,虫子没有了。

安全专家、White Hat Security CTO杰雷米亚·格罗斯曼(Jeremiah Grossman)表示,或许Chrome有所不同,但这将取决于哪一方首先发现软件中的漏洞。他预测称,Chrome的第一个漏洞将会在24小时内被发现。格罗斯曼称:“即使拥有所有正确的设计概念,但如果忘记一行代码,一切都毫无意义。”


本帖一共被 1 帖 引用 (帖内工具实现)
全看分页树展 · 主题 跟帖


有趣有益,互惠互利;开阔视野,博采众长。
虚拟的网络,真实的人。天南地北客,相逢皆朋友

Copyright © cchere 西西河