Now Hacked
ZH

今日安全题 #9

这是 2026-11-09 的题目。 阅读代码,选出最严重的安全漏洞。

中等JavaScript (Node.js)2026-11-09

这是一个将用户设置与默认值合并的函数。body 是请求的 JSON。最严重的漏洞是什么?

function merge(target, source) {
  for (const key in source) {
    if (typeof source[key] === 'object' && source[key] !== null) {
      target[key] = merge(target[key] ?? {}, source[key]);
    } else {
      target[key] = source[key];
    }
  }
  return target;
}
 
const settings = merge({}, req.body);

往期题目