官方:https://jsxss.com/zh/index.html

xss csrf https://www.cnblogs.com/443855539-wind/p/6055816.html

一、通用方法:Token   使用Anti-CSRF Token   在URL中保持原参数不变,新增一个参数Token。Token的值是随机的(必须使用足够安全的随机数生成算法,或者采用真随机数生成器),其为用户与服务器所共同持有,可以放在用户的Session中,或者浏览器的Cookie中。 注意保密,尽量把Token放在表单中(构造一个隐藏的input元素),以POST提交,避免Token泄露。

二、以nodejs做测试

1.在终端引入xss,命令:

npm install xss --save
 2.在vue的页面进行引入

import xss from 'xss'
3.定义一个变量进行测试

首先测试一个没有进行防止xss攻击的测试

<p v-html="test"></p>

export default {
data () {
return {
test: `<a onclick='alert("xss攻击")'>链接</a>`
}
}

结果,js事件直接被翻译了

因此应该杜绝这些情况,解决方法如下

4

<p v-html="$xss(test)"></p>

import xss from 'xss'
export default {
data () {
return {
test: `<a onclick='alert("xss攻击")'>链接</a>`
}
}

Object.defineProperty(Vue.prototype, '$xss', {
value: xss
})
此时a标签会保留,但是onclick事件被拦截了
---------------------
作者:logytar
来源:CSDN
原文:https://blog.csdn.net/qiumen/article/details/88119275
版权声明:本文为博主原创文章,转载请附上博文链接!

防xss攻击的更多相关文章

  1. 【前端安全】JavaScript防XSS攻击

    什么是XSS XSS(Cross Site Scripting),跨站脚本攻击,是一种允许攻击者在另外一个用户的浏览器中执行恶意代码脚本的脚本注入式攻击.本来缩小应该是CSS,但为了和层叠样式(Cas ...

  2. HTML标签防XSS攻击过滤模块--待优化

    HTML标签防XSS攻击过滤模块 http://cnodejs.org/topic/5058962f8ea56b5e7806b2a3

  3. java请求URL带参之防XSS攻击

    1.web.xml新增filter配置 <!-- URL请求参数字符过滤或合法性校验 --> <filter> <filter-name>XssFilter< ...

  4. webform非表单提交时防xss攻击

     1.webform默认配置下,主动防御了针对表单提交的xss攻击,但这次发生时因为url导致的,所以webform的默认防御机制不起作用  webform下输出非表单提交获得的数据的时候,要加htm ...

  5. PHP 防xss攻击

    PHP直接输出html的,可以采用以下的方法进行过滤: 1.htmlspecialchars函数 2.htmlentities函数 3.HTMLPurifier.auto.php插件 4.Remove ...

  6. SpringBoot防XSS攻击

    1 . pom中增加依赖 <!-- xss过滤组件 --> <dependency> <groupId>org.jsoup</groupId> < ...

  7. [BUGCASE]CI框架的post方法对url做了防xss攻击的处理引发的文件编码错误

    一.问题描述 出现问题的链接: http://adm.apply.wechat.com/admin/index.php/order/detail?country=others&st=1& ...

  8. node防xss攻击插件

    var xss = require('node-xss').clean; router.post("/orders/insert-orders", function (req, r ...

  9. 防XSS攻击解决方法

    1.web.xml文件中新增filter配置 <!-- URL请求参数字符过滤或合法性校验 --> <filter> <filter-name>XssFilter& ...

随机推荐

  1. [Swift]LeetCode233. 数字1的个数 | Number of Digit One

    Given an integer n, count the total number of digit 1 appearing in all non-negative integers less th ...

  2. [Swift]LeetCode264.丑数 II | Ugly Number II

    Write a program to find the n-th ugly number. Ugly numbers are positive numbers whose prime factors ...

  3. [Swift]LeetCode371. 两整数之和 | Sum of Two Integers

    Calculate the sum of two integers a and b, but you are not allowed to use the operator + and -. Exam ...

  4. [Swift]LeetCode695. 岛屿的最大面积 | Max Area of Island

    Given a non-empty 2D array grid of 0's and 1's, an island is a group of 1's (representing land) conn ...

  5. 容器云架构中使用gorouter+haproxy作为流量入口

    ​ 小贴士 Gorouter 项目地址:https://github.com/cloudfoundry/gorouter/Gorouter来源于CloudFoundry.是一个高性能.轻量级的路由器及 ...

  6. 【Sqoop篇】----Sqoop从搭建到应用案例

    一.前述 今天开始讲解Sqoo的用法搭建和使用.Sqoop其实功能非常简单.主要用于在Hadoop(Hive)与传统的数据库(mysql.postgresql...)间进行数据的传递,可以将一个关系型 ...

  7. Python内置函数(19)——eval

    英文文档: eval(expression, globals=None, locals=None) The arguments are a string and optional globals an ...

  8. golang子进程的启动和停止,mac与linux的区别

    今天接到一个任务是将原来运行在mac的应用移植到linux,原因当然是因为客户那边当前是linux环境,也不想再采购mac电脑. 通常来说,这个工作并不难,因为我选用的服务器端技术是c或者golang ...

  9. [Leetcode]112. Path Sum -David_Lin

    Given a binary tree and a sum, determine if the tree has a root-to-leaf path such that adding up all ...

  10. Java开发知识之XML文档使用,解析

    目录 XML文件详解 一丶XML简介 1.文档结构 2.XML中的元素(Element)或者叫做标签(Tab).属性 文本内容. 节点(Node) 3.XML语法规则 二丶XML文档解析 三丶使用XP ...