Skip to content

Commit

Permalink
Fix xss vulnerability (#418)
Browse files Browse the repository at this point in the history
Co-authored-by: Viktor Baranov <baranov.viktor.27@gmail.com>
  • Loading branch information
Enrique Ruiz and vbaranov authored Oct 6, 2021
1 parent 6e233ee commit 8484e47
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
### Features

### Fixes
- [#4713](https://github.com/blockscout/blockscout/pull/4713) - Search input field: sanitize input

### Chore

Expand Down
4 changes: 4 additions & 0 deletions apps/block_scout_web/assets/js/lib/autocomplete.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import AutoComplete from '@tarekraafat/autocomplete.js/dist/autoComplete.js'
import { getTextAdData, fetchTextAdData } from './ad.js'
import { DateTime } from 'luxon'
import xss from 'xss'

const placeHolder = 'Search by address, token symbol, name, transaction hash, or block number'
const dataSrc = async (query, id) => {
Expand Down Expand Up @@ -106,6 +107,9 @@ const config = (id) => {
element: (item, data) => resultItemElement(item, data),
highlight: 'autoComplete_highlight'
},
query: (input) => {
return xss(input)
},
events: {
input: {
focus: () => {
Expand Down
21 changes: 17 additions & 4 deletions apps/block_scout_web/assets/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion apps/block_scout_web/assets/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,8 @@
"urijs": "^1.19.7",
"url": "^0.11.0",
"util": "^0.12.4",
"web3": "^1.5.2"
"web3": "^1.5.2",
"xss": "^1.0.9"
},
"devDependencies": {
"@babel/core": "^7.14.6",
Expand Down

0 comments on commit 8484e47

Please sign in to comment.