Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8215079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T11:40:08+00:00 2026-06-07T11:40:08+00:00

In order to have an URL friendly application I’m storing it’s context has a

  • 0

In order to have an URL friendly application I’m storing it’s context has a JSON in URL, which gives something like :

http://mysite.dev/myapppage/target#?context={%22attr1%22%3A{%22target_id-0%22%3A{%22value%22%3A%223%22%2C%22label%22%3A%22Hello%22}}}

Which encode a basic context :

{
"attr1":
    {
    "target_id-0":
        {
        "value": "3",
        "label": "Hello"
        }
    }
}

I’m serializing my object with :

JSON.stringify(context)

I’m deserializing it with :

var hashParamsElements = window.location.toString().split('?');
hashParamsElements.shift(); // we just skip the first part of the url
var hashParams = $.deparam(hashParamsElements.join('?'));
var contextString = hashParams.context;
var context = JSON.parse(contextString);

The context is only stored to read variables, there’s no evaluated code in it. Can someone tell me whether or not it’s XSS safe ?

If there’s a threat : how can I avoid it ?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-07T11:40:10+00:00Added an answer on June 7, 2026 at 11:40 am

    A threat of this kind comes from using different methods of decoding JSON, namely eval and new Function. These execute JS code directly and therefore allow non-persistent XSS attacks by putting code in the url (and linking to it).

    JSON.parse does not have this issue and is safe against these kind of attacks.

    See also (json.org).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a URL like this http://www.mysite.com/one/two/nearly_anything#!0lJ_PghzRwHtOyL3BkSouCFVh61mV_I0ZUPSipZDKPFW9xc from which I need to get the
I have a url which could be www.website.com/order/?pg3=2 or www.website.com/orderstatus/?pg2= There could be several
I would like to match url pattern that has optional segments. I have URL-s
i have a Real Estate site and i like to order the url of
I have url like this which is a js file example like this link
I have a URL formatted like this: http://testsite1/mm/page1.php?tID=18&tSerial=TEST TT 1 And here is my
We use MixedParamHybridUrlCodingStrategy in our Wicket application in order to have pretty url parsed
I have a url that looks something like this: zigzagstudio/#!/page_wedding2 and I need to
I have a URL with the following format: http://domain.com/checkout/nonce/701fe0f652/order/108/?token=EC-0DS37792JX3680821 I try to convert it
I have first: select url from urls where site = '$value' order by url

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.