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 6875383
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T04:18:57+00:00 2026-05-27T04:18:57+00:00

I have a disagreement with a security auditor, whether a snippet of html/js is

  • 0

I have a disagreement with a security auditor, whether a snippet of html/js is vulnerable to XSS or not.

In short this is it:

<html>
<form name="myform" action="page.php" method="post" onsubmit="return validate()">
<input name="field" type="text" size="50" />
<input type="submit" value="Submit" />
</form>

<script>
function validate()
{
  var str=document.myform.field.value;
  alert("Error in " + str);
  return false
}
</script>
</html>

So, my auditor says that this can be vulnerable to DOM-based XSS, but has not yet given me an example.

I personally think that it is not, since because of the + inside alert, str is a string so it’s not executed. For example if someone provides “document.cookie” in the form and hits submit, then the alert box is going to print “Error in document.cookie” (and not the actual cookie).

  • 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-05-27T04:18:58+00:00Added an answer on May 27, 2026 at 4:18 am

    The only way this could be a potential threat is if you are including scripts that are not under your control from an untrustworthy source.

    • The malicious script could overwrite alert to be another function. For example, it could send the data passed to alert to its own servers.
    • The malicious script could overwrite the value of document.myform.field with an object containing a value property. The alert could be thus made to display a message that looked like a different error message, such as:

    Error in authentication. Please go to http://www.phisherman.com and enter your user name and password.

    If you are linking to scripts from untrustworthy sources, you have much greater security concerns than the above.

    If you are linking to no such untrustworthy scripts, then no, this is not vulnerable to DOM-based XSS. form.field.value contains a string. It is not evaluated as script, escape characters have no effect, the string contained in the textbox will be displayed in the alert window. Nothing a user enters in that field could be used to harm your servers or corrupt your data based on the code you’ve posted.

    I’d say that if your auditor is concerned with “DOM-based XSS” where-in a user might cause harm to your servers by manipulating the DOM, your auditor does not know much about DOM and browser-based JavaScript. A user can crack open a JavaScript console and execute all manner of scripts, including XMLHttpRequests to your server that can be made to look like they came from your own script. Precautions need to be made on the server for those types of attacks. Worrying about the security risks to the DOM or UI from user input in form fields is silly.

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

Sidebar

Related Questions

have a problem. At first look at this HTML <div id=map style=background-image: url(map.png); width:
I have a friend who is in disagreement with me on this, and I'm
Have: [DllImport(OpenAL32.dll)] static extern void alcOpenDevice(char*[] devicename); Wanna send the name to this function
@usr and I are having a disagreement in another question about whether or not
have written this little class, which generates a UUID every time an object of
Have been trying to figure this problem out for a while now and was
Have written all the code in a silverlight class library (dll) and linked this
TL;DR Version : This question has arisen due to the fact that I have
I have been researching this for the past hour, and yet to come up
Have been trying to figure this out for an hour - and still have

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.