官方: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]LeetCode205. 同构字符串 | Isomorphic Strings

    Given two strings s and t, determine if they are isomorphic. Two strings are isomorphic if the chara ...

  2. [Swift]LeetCode236. 二叉树的最近公共祖先 | Lowest Common Ancestor of a Binary Tree

    Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...

  3. [Swift]LeetCode542. 01 矩阵 | 01 Matrix

    Given a matrix consists of 0 and 1, find the distance of the nearest 0 for each cell. The distance b ...

  4. [Swift]LeetCode923.三数之和的多种可能 | 3Sum With Multiplicity

    Given an integer array A, and an integer target, return the number of tuples i, j, k  such that i &l ...

  5. Java接口实现传参

    package com.gezhi.interfaces;/** * 新建一个dog类实现接口livingable(狗吃和上厕所都是与生俱来的不应该写成接口) * @author square 凉 * ...

  6. 汉诺塔问题其实很简单 Python 递归经典面试题

    话不多说,上代码 1 def hanoi_move(n, source, dest, intermediate): 2 if n >= 1: # 递归出口,只剩一个盘子 3 hanoi_move ...

  7. C++版 - UVa1585 Score - 题解

    C++版 - UVa1585 Score - 题解 <算法竞赛入门经典(第二版)> 习题3-1 得分(ACM/ICPC Seoul 2005,UVa1585) 问题描述: 给出一个由O和X ...

  8. Chapter 5 Blood Type——5

    "Well…" He paused, and then the rest of the words followed in a rush. "嗯..." 他顿顿 ...

  9. leetcode — populating-next-right-pointers-in-each-node

    /** * * Source : https://oj.leetcode.com/problems/populating-next-right-pointers-in-each-node/ * Sou ...

  10. 开发函数计算的正确姿势 —— 使用 Fun Local 本地运行与调试

    前言 首先介绍下在本文出现的几个比较重要的概念: 函数计算(Function Compute): 函数计算是一个事件驱动的服务,通过函数计算,用户无需管理服务器等运行情况,只需编写代码并上传.函数计算 ...