为了账号安全,请及时绑定邮箱和手机立即绑定

为什么我设置 res.set('X-XSS-Protection',0);不起作用?

<img src="null" onerror="alert"1"/>依旧被浏览器屏蔽

router.get('/', function(req, res, next) {

  // 阻止浏览器的XSS拦截

  res.set('X-XSS-Protection',0);

  res.render('index', { title: 'Express', xss:req.query.xss});

});

控制台错误信息:

localhost/:11 The XSS Auditor refused to execute a script in 'http://localhost:3000/?xss=%3Cimg%20src=%22null%22%20onerror=%22alert(1)%22/%3E' because its source code was found within the request. The auditor was enabled as the server did not send an 'X-XSS-Protection' header.

?xss=<img src="null" onerror="alert(1)"/>:11 GET http://localhost:3000/null 404 (Not Found)


正在回答

3 回答

对,要强刷一下才可以

0 回复 有任何疑惑可以回复我~

chrome可以起作用,你可以重新起了服务之后重新输入url的search代码,应该就可以正常弹出来了

0 回复 有任何疑惑可以回复我~
#1

赵成冬

有缓存?
2017-09-30 回复 有任何疑惑可以回复我~

我用Chrome,写了也没效果,打开IE就可以弹出来了,不知道是不是Chrome不能关掉

0 回复 有任何疑惑可以回复我~
#1

铭记4

你解决了吗,我也碰到这个问题
2017-04-27 回复 有任何疑惑可以回复我~
#2

安可心_believe 回复 铭记4

应该是有缓存,ctrl+F5刷新下就可以弹出来了。
2017-10-15 回复 有任何疑惑可以回复我~

举报

0/150
提交
取消
Web安全-XSS
  • 参与学习       35584    人
  • 解答问题       71    个

从Web安全XSS的定义开始讲起,从原理到实战全方位理解XSS安全

进入课程

为什么我设置 res.set('X-XSS-Protection',0);不起作用?

我要回答 关注问题
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号