Skip to content

Commit

Permalink
Merge pull request #1195 from Nuzhy-Deriv/update-cookiejs
Browse files Browse the repository at this point in the history
fix: cookies injection vulnerabilty
  • Loading branch information
behnaz-deriv authored Jun 8, 2023
2 parents 800a531 + 5928629 commit cd94e01
Showing 1 changed file with 2 additions and 3 deletions.
5 changes: 2 additions & 3 deletions public/scripts/cookie.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ const shouldOverwrite = (new_utm_data, current_utm_data) => {
];

let utm_data = {};
const current_utm_data = JSON.parse(getCookie("utm_data"));
const current_utm_data = JSON.parse(decodeURIComponent(getCookie("utm_data")));

// If the user comes to the site for the first time without any URL params
// Only set the utm_source to referrer if the user does not have utm_data cookies stored
Expand All @@ -110,7 +110,6 @@ const shouldOverwrite = (new_utm_data, current_utm_data) => {
if (searchParams.has(field)) {
utm_data[field] = searchParams
.get(field)
.replace(/[^a-zA-Z0-9\s\-\.\_]/gi, "")
.substring(0, 100); // Limit to 100 supported characters
}
});
Expand All @@ -119,7 +118,7 @@ const shouldOverwrite = (new_utm_data, current_utm_data) => {
eraseCookie("affiliate_tracking");
eraseCookie("utm_data");

const utm_data_cookie = encodeURI(JSON.stringify(utm_data))
const utm_data_cookie = encodeURIComponent(JSON.stringify(utm_data))
.replaceAll("%2C", ",")
.replaceAll("%7B", "{")
.replaceAll("%7D", "}");
Expand Down

0 comments on commit cd94e01

Please sign in to comment.