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

  • Home
  • SEARCH
  • 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 65843
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T19:00:36+00:00 2026-05-10T19:00:36+00:00

We have a high security application and we want to allow users to enter

  • 0

We have a high security application and we want to allow users to enter URLs that other users will see.

This introduces a high risk of XSS hacks – a user could potentially enter javascript that another user ends up executing. Since we hold sensitive data it’s essential that this never happens.

What are the best practices in dealing with this? Is any security whitelist or escape pattern alone good enough?

Any advice on dealing with redirections (‘this link goes outside our site’ message on a warning page before following the link, for instance)

Is there an argument for not supporting user entered links at all?


Clarification:

Basically our users want to input:

stackoverflow.com

And have it output to another user:

<a href='http://stackoverflow.com'>stackoverflow.com</a> 

What I really worry about is them using this in a XSS hack. I.e. they input:

alert(‘hacked!’);

So other users get this link:

<a href='javascript:alert('hacked!');'>stackoverflow.com</a> 

My example is just to explain the risk – I’m well aware that javascript and URLs are different things, but by letting them input the latter they may be able to execute the former.

You’d be amazed how many sites you can break with this trick – HTML is even worse. If they know to deal with links do they also know to sanitise <iframe>, <img> and clever CSS references?

I’m working in a high security environment – a single XSS hack could result in very high losses for us. I’m happy that I could produce a Regex (or use one of the excellent suggestions so far) that could exclude everything that I could think of, but would that be enough?

  • 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. 2026-05-10T19:00:36+00:00Added an answer on May 10, 2026 at 7:00 pm

    If you think URLs can’t contain code, think again!

    https://owasp.org/www-community/xss-filter-evasion-cheatsheet

    Read that, and weep.

    Here’s how we do it on Stack Overflow:

    /// <summary> /// returns "safe" URL, stripping anything outside normal charsets for URL /// </summary> public static string SanitizeUrl(string url) {     return Regex.Replace(url, @"[^-A-Za-z0-9+&@#/%?=~_|!:,.;\(\)]", ""); } 
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 152k
  • Answers 152k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer You can use event delegation, to basically connect only one… May 12, 2026 at 10:09 am
  • Editorial Team
    Editorial Team added an answer As far as I can tell you need an ILabelDecorator… May 12, 2026 at 10:09 am
  • Editorial Team
    Editorial Team added an answer It's almost always a mistake to set local variables to… May 12, 2026 at 10:09 am

Related Questions

I have a Delphi (5) application that uses a log-in screen (standard user name/password)
I'm writing an Android App and I'm looking for the fastest (In terms of
Here's my situation... I'm writing a .Net/C# security system (authorization and authentication) for a
I have an application containing 4 MDB's each of which receives SOAP messages over

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.