Skip to content

Commit 9486350

Browse files
committed
XSS fixes
1 parent 001d74a commit 9486350

File tree

4 files changed

+48
-6
lines changed

4 files changed

+48
-6
lines changed

ui/package-lock.json

Lines changed: 30 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

ui/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
},
1010
"dependencies": {
1111
"axios": "^1.7.4",
12+
"dompurify": "^3.2.4",
1213
"is-cidr": "^3.1.1",
1314
"moment": "^2.29.4",
1415
"postcss": ">=8.5.3",

ui/src/App.vue

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
import Footer from "./components/Footer";
2020
import TokenService from "./services/token.service";
2121
import ApiService from "./services/api.service";
22+
import DOMPurify from 'dompurify';
2223
import {mapActions, mapGetters} from "vuex";
2324
2425
export default {
@@ -64,15 +65,17 @@
6465
6566
mounted() {
6667
if (this.$route && this.$route.query && this.$route.query.redirect_uri) {
67-
TokenService.saveRedirect(this.$route.query.redirect_uri)
68-
TokenService.destroyToken() // force a token exchange
68+
if (TokenService.isValidRedirect(this.$route.query.redirect_uri)) {
69+
TokenService.saveRedirect(this.$route.query.redirect_uri)
70+
TokenService.destroyToken() // force a token exchange
71+
}
6972
}
7073
if (this.$route && this.$route.query && this.$route.query.code && this.$route.query.state) {
7174
72-
let redirect = TokenService.getRedirect()
75+
let redirect = DOMPurify.sanitize(TokenService.getRedirect());
7376
if (redirect != null && redirect != "") {
7477
TokenService.destroyRedirect()
75-
var url = redirect + "?code=" + this.$route.query.code + "&state=" + this.$route.query.state + "&client_id=" + TokenService.getClientId();
78+
var url = redirect + "?code=" + DOMPurify.sanitize(this.$route.query.code) + "&state=" + DOMPurify.sanitize(this.$route.query.state) + "&client_id=" + TokenService.getClientId();
7679
window.location.replace(url);
7780
return;
7881
}

ui/src/services/token.service.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ export const destroyClientId = () => {
117117
window.localStorage.removeItem(CLIENT_ID_KEY);
118118
};
119119

120+
const AUTHORIZED_REDIRECTS = [
121+
'https://my.nettica.com'
122+
];
123+
124+
export const isValidRedirect = (url) => {
125+
return AUTHORIZED_REDIRECTS.includes(url);
126+
};
127+
120128
export default {
121129
getRedirect,
122130
saveRedirect,
@@ -144,5 +152,6 @@ export default {
144152
destroyState,
145153
getCode,
146154
saveCode,
147-
destroyCode
155+
destroyCode,
156+
isValidRedirect
148157
};

0 commit comments

Comments
 (0)