Web Server Scripting Issues

ITPro Today

February 2, 2000

14 Min Read
ITPro Today logo in a gray background | ITPro Today

Web Server Scripting Issues
Reported Feburary 2, 2000 by CERT VERSIONS AFFECTED

  • Web Servers that do not validate input from dynamically generated pages

  • Web browsers

DESCRIPTION

A copy of the original CERT advisory follows in its entirety:

 

CERT® Advisory CA-2000-02 Malicious HTML Tags Embedded in Client Web Requests

This advisory is being published jointly by the CERT Coordination Center, DoD-CERT, the DoD Joint Task Force for Computer Network Defense (JTF-CND), the Federal Computer Incident Response Capability (FedCIRC), and the National Infrastructure Protection Center (NIPC).

Original release date: February 2, 2000
Last revised: February 3, 2000

A complete revision history is at the end of this file.

Systems Affected

  • Web browsers

  • Web servers that dynamically generate pages based on unvalidated input


Overview

A web site may inadvertently include malicious HTML tags or script in a dynamically generated page based on unvalidated input from untrustworthy sources. This can be a problem when a web server does not adequately ensure that generated pages are properly encoded to prevent unintended execution of scripts, and when input is not validated to prevent malicious HTML from being presented to the user.

I. Description

Background

Most web browsers have the capability to interpret scripts embedded in web pages downloaded from a web server. Such scripts may be written in a variety of scripting languages and are run by the client"s browser. Most browsers are installed with the capability to run scripts enabled by default.

Malicious code provided by one client for another client

Sites that host discussion groups with web interfaces have long guarded against a vulnerability where one client embeds malicious HTML tags in a message intended for another client. For example, an attacker might post a message like

Hello message board. This is a message.
malicious code
This is the end of my message.

When a victim with scripts enabled in their browser reads this message, the malicious code may be executed unexpectedly. Scripting tags that can be embedded in this way include , <OBJECT>, <APPLET>, and <EMBED>. </p> <p>When client-to-client communications are mediated by a server, site developers explicitly recognize that data input is untrustworthy when it is presented to other users. Most discussion group servers either will not accept such input or will encode/filter it before sending anything to other readers. </p> <h4>Malicious code sent inadvertently by a client for itself</h4> <p>Many Internet web sites overlook the possibility that a client may send malicious data intended to be used only by itself. This is an easy mistake to make. After all, why would a user enter malicious code that only the user will see? </p> <p>However, this situation may occur when the client relies on an untrustworthy source of information when submitting a request. For example, an attacker may construct a malicious link such as </p><dl><dd><A HREF="http://example.com/comment.cgi? mycomment=<SCRIPT>malicious code"> Click here

When an unsuspecting user clicks on this link, the URL sent to example.com includes the malicious code. If the web server sends a page back to the user including the value of mycomment, the malicious code may be executed unexpectedly on the client. This example also applies to untrusted links followed in email or newsgroup messages.

Abuse of other tags

In addition to scripting tags, other HTML tags such as the tag have the potential to be abused by an attacker. For example, by embedding malicious tags at the right place, an intruder can trick users into revealing sensitive information by modifying the behavior of an existing form. Other HTML tags can also be abused to alter the appearance of the page, insert unwanted or offensive images or sounds, or otherwise interfere with the intended appearance and behavior of the page.

Abuse of trust

At the heart of this vulnerability is the violation of trust that results from the "injected" script or HTML running within the security context established for the example.com site. It is, presumably, a site the browser victim is interested in enough to visit and interact with in a trusted fashion. In addition, the security policy of the legitimate server site example.com may also be compromised.

This example explicitly shows the involvement of two sites:

"> Click here

Note the SRC attribute in the tag is explicitly incorporating code from a presumably unauthorized source (<i>bad-site</i>). Both of the previous examples show violations of the same-source origination policy fundamental to most scripting security models: </p><dl><dd><a href="https://developer.netscape.com/docs/manuals/communicator/jssec/contents.htm#1023448" target="_blank">Netscape Communicator Same Origin Policy</a> <br><a href="https://msdn.microsoft.com/library/partbook/dhtml/scriptletsecurity.htm" target="_blank">Microsoft Scriptlet Security</a> </dd><dt> </dt></dl><p>Because one source is injecting code into pages sent by another source, this vulnerability has also been described as "cross-site" scripting. </p> <p>At the time of publication, malicious exploitation of this vulnerability has not been reported to the CERT/CC. However, because of the potential for such exploitation, we recommend that organization CIOs, managers, and system administrators aggressively implement the steps listed in the <a href="https://www.itprotoday.com/article/security/web-server-scripting-issues-9503#solution">solution</a> section of this document. Technical feedback to appropriate technical, operational, and law enforcement authorities is encouraged. <a name="impact" id="impact"></a> </p> <h3>II. Impact</h3> <p>Users may unintentionally execute scripts written by an attacker when they follow untrusted links in web pages, mail messages, or newsgroup postings. Users may also unknowingly execute malicious scripts when viewing dynamically generated pages based on content provided by other users. </p> <p>Because the malicious scripts are executed in a context that appears to have originated from the targeted site, the attacker has full access to the document retrieved (depending on the technology chosen by the attacker), and may send data contained in the page back to their site. For example, a malicious script can read fields in a form provided by the real server, then send this data to the attacker. </p> <p>Note that the access that an intruder has to the Document Object Model (DOM) is dependent on the security architecture of the language chosen by the attacker. Specifically, Java applets do not provide the attacker with any access to the DOM. </p> <p>Alternatively, the attacker may be able to embed script code that has additional interactions with the legitimate web server without alerting the victim. For example, the attacker could develop an exploit that posted data to a different page on the legitimate web server. </p> <p>Also, even if the victim"s web browser does not support scripting, an attacker can alter the appearance of a page, modify its behavior, or otherwise interfere with normal operation. </p> <p>The specific impact can vary greatly depending on the language selected by the attacker and the configuration of any authentic pages involved in the attack. Some examples that may not be immediately obvious are included here. </p> <h4>SSL-Encrypted Connections May Be Exposed</h4> <p>The malicious script tags are introduced before the Secure Socket Layer (SSL) encrypted connection is established between the client and the legitimate server. SSL encrypts data sent over this connection, including the malicious code, which is passed in both directions. While ensuring that the client and server are communicating without snooping, SSL makes no attempt to validate the legitimacy of data transmitted. </p> <p>Because there really is a legitimate dialog between the client and the server, SSL reports no problems. Malicious code that attempts to connect to a non-SSL URL may generate warning messages about the insecure connection, but the attacker can circumvent this warning simply by running an SSL-capable web server. </p> <h4>Attacks May Be Persistent Through Poisoned Cookies</h4> <p>Once malicious code is executing that appears to have come from the authentic web site, cookies may be modified to make the attack persistent. Specifically, if the vulnerable web site uses a field from the cookie in the dynamic generation of pages, the cookie may be modified by the attacker to include malicious code. Future visits to the affected web site (even from trusted links) will be compromised when the site requests the cookie and displays a page based on the field containing the code. </p> <h4>Attacker May Access Restricted Web Sites from the Client</h4> <p>By constructing a malicious URL an attacker may be able to execute script code on the client machine that exposes data from a vulnerable server inside the client"s intranet. </p> <p>The attacker may gain unauthorized web access to an intranet web server if the compromised client has cached authentication for the targeted server. There is no requirement for the attacker to masquerade as any particular system. An attacker only needs to identify a vulnerable intranet server and convince the user to visit an innocent looking page to expose potentially sensitive data on the intranet server. </p> <h4>Domain Based Security Policies May Be Violated</h4> <p>If your browser is configured to allow execution of scripting languages from some hosts or domains while preventing this access from others, attackers may be able to violate this policy. </p> <p>By embedding malicious script tags in a request sent to a server that is allowed to execute scripts, an attacker may gain this privilege as well. For example, Internet Explorer security "zones" can be subverted by this technique. </p> <h4>Use of Less-Common Character Sets May Present Additional Risk</h4> <p>Browsers interpret the information they receive according to the character set chosen by the user if no character set is specified in the page returned by the web server. However, many web sites fail to explicitly specify the character set (even if they encode or filter characters with special meaning in the ISO-8859-1), leaving users of alternate character sets at risk. </p> <h4>Attacker May Alter the Behavior of Forms</h4> <p>Under some conditions, an attacker may be able to modify the behavior of forms, including how results are submitted. <a name="solution" id="solution"></a> </p> <h3>III. Solution</h3> <h4>Solutions for Users</h4> <p>None of the solutions that web users can take are complete solutions. In the end, it is up to web page developers to modify their pages to eliminate these types of problems. </p> <p>However, web users have two basic options to reduce their risk of being attacked through this vulnerability. The first, disabling scripting languages in their browser, provides the most protection but has the side effect for many users of disabling functionality that is important to them. Users should select this option when they require the lowest possible level of risk. </p> <p>The second solution, being selective about how they initially visit a web site, will significantly reduce a user"s exposure while still maintaining functionality. Users should understand that they are accepting more risk when they select this option, but are doing so in order to preserve functionality that is important to them. </p> <p>Unfortunately, it is not possible to quantify the risk difference between these two options. Users who decide to continue operating their browsers with scripting languages enabled should periodically revisit the CERT/CC web site for updates, as well as review other sources of security information to learn of any increases in threat or risk related to this vulnerability. </p> <h5>Web Users Should Disable Scripting Languages in Their Browsers</h5> <p>Exploiting this vulnerability to execute code requires that some form of embedded scripting language be enabled in the victim"s browser. The most significant impact of this vulnerability can be avoided by disabling all scripting languages. </p> <p>Note that attackers may still be able to influence the appearance of content provided by the legitimate site by embedding other HTML tags in the URL. Malicious use of the <FORM> tag in particular is not prevented by disabling scripting languages. </p> <p>Detailed instructions to disable scripting languages in your browser are available from our Malicious Code FAQ: </p><dl><dd><a href="https://www.cert.org/tech_tips/malicious_code_FAQ.html" target="_blank">http://www.cert.org/tech_tips/malicious_code_FAQ.html</a> </dd><dt> </dt></dl><h5>Web Users Should Not Engage in Promiscuous Browsing</h5> <p>Some users are unable or unwilling to disable scripting languages completely. While disabling these scripting capabilities is the most effective solution, there are some techniques that can be used to reduce a user"s exposure to this vulnerability. </p> <p>Since the most significant variations of this vulnerability involve cross-site scripting (the insertion of tags into another site"s web page), users can gain some protection by being selective about how they initially visit a web site. Typing addresses directly into the browser (or using securely stored local bookmarks) is likely to be the safest way of connecting to a site. </p> <p>Users should be aware that even links to unimportant sites may expose other local systems on the network if the client"s system resides behind a firewall, or if the client has cached credentials to access other web servers (e.g., for an intranet). For this reason, cautious web browsing is <b>not</b> a comparable substitute for disabling scripting. </p> <p>With scripting enabled, visual inspection of links does not protect users from following malicious links, since the attacker"s web site may use a script to misrepresent the links in the user"s window. For example, the contents of the Goto and Status bars in Netscape are controllable by JavaScript. </p> <h4>Solutions for Web Page Developers and Web Site Administrators</h4> <h5>Web Page Developers Should Recode Dynamically Generated Pages to Validate Output</h5> <p>Web site administrators and developers can prevent their sites from being abused in conjunction with this vulnerability by ensuring that dynamically generated pages do not contain undesired tags. </p> <p>Attempting to remove dangerous meta-characters from the input stream leaves a number of risks unaddressed. We encourage developers to restrict variables used in the construction of pages to those characters that are explicitly allowed and to check those variables during the generation of the output page. </p> <p>In addition, web pages should explicitly set a character set to an appropriate value in all dynamically generated pages. </p> <p>Because encoding and filtering data is such an important step in responding to this vulnerability, and because it is a complicated issue, the CERT/CC has written a document which explores this issue in more detail: </p><dl><dd><a href="https://www.cert.org/tech_tips/malicious_code_mitigation.html/" target="_blank">http://www.cert.org/tech_tips/malicious_code_mitigation.html</a> </dd><dt> </dt></dl><h5>Web Server Administrators Should Apply a Patch From Their Vendor</h5> <p>Some web server products include dynamically generated pages in the default installation. Even if your site does not include dynamic pages developed locally, your web server may still be vulnerable. For example, your server may include malicious tags in the "404 Not Found" page generated by your web server. </p> <p>Web server administrators are encouraged to apply patches as suggested by your vendor to address this problem. <a href="https://www.itprotoday.com/article/security/web-server-scripting-issues-9503#vendors">Appendix A</a> contains information provided by vendors for this advisory. We will update the appendix as we receive more information. If you do not see your vendor"s name, the CERT/CC did not hear from that vendor. Please contact your vendor directly. <a name="vendors" id="vendors"></a> </p> <h3>Appendix A. Vendor Information</h3> <h4>Apache</h4> <p>More information from apache can be found at </p><dl><dd><a href="https://www.apache.org/info/css-security/" target="_blank">http://www.apache.org/info/css-security</a> </dd><dt> </dt></dl><h4>iPlanet - A Sun-Netscape Alliance</h4> <p>Additional information from iPlanet can be found at: </p><dl><dd><a href="https://developer.iplanet.com/docs/technote/security/cert_ca2000_02.html" target="_blank">http://developer.iplanet.com/docs/technote/security/cert_ca2000_02.html</a> </dd><dt> </dt></dl><h4>Microsoft</h4> <p>Microsoft is providing information and assistance on this issue for its customers. This information will be posted at <a href="https://www.microsoft.com/security" target="_blank">www.microsoft.com/security/</a>. </p> <h4>Sun Microsystems, Inc.</h4> <p>Please see recommendations for Java Web Server at: </p><dl><dd><a href="https://sun.com/software/jwebserver/faq/jwsca-2000-02.html" target="_blank">http://sun.com/software/jwebserver/faq/jwsca-2000-02.html</a> </dd><dt> </dt></dl><p>Sun is also providing information on security issues in general.&nbsp; This information is posted at </p><dl><dd><a href="https://java.sun.com/security" target="_blank">http://java.sun.com/security</a> </dd><dt> </dt></dl><p>A good introduction is in <a href="https://java.sun.com/sfaq" target="_blank">http://java.sun.com/sfaq</a> </p> <p>While any web-based object, including Java Applets, can be unintentionally loaded through the mechanisms described in this advisory, once they are loaded the Java security mechanisms prevent any harmful information from being disclosed or client information from being damaged. </p> <p>&nbsp;</p> <hr noshade><p>Our thanks to Marc Slemko, Apache Software Foundation member; Iris Associates; iPlanet; the Microsoft Security Response Center, the Microsoft Internet Explorer Security Team, and Microsoft Research. </p> <p>&nbsp;</p> <hr noshade width="100%"><p>This document is available from: <a href="https://www.cert.org/advisories/CA-2000-02.html" target="_blank">http://www.cert.org/advisories/CA-2000-02.html</a> </p> <hr noshade width="100%"><h3>CERT/CC Contact Information</h3> <dl><dd><p>Email: <a href="mailto:[email protected]">[email protected]</a><br><b>Phone:</b> +1 412-268-7090 (24-hour hotline)<br><b>Fax:</b> +1 412-268-6989<br><b>Postal address:</b><br></p> </dd><dd>CERT<sup>®</sup> Coordination Center<br> Software Engineering Institute<br> Carnegie Mellon University<br> Pittsburgh PA 15213-3890<br> U.S.A.<br></dd><dt> </dt></dl><p>CERT personnel answer the hotline 08:00-20:00 EST(GMT-5) / EDT(GMT-4) Monday through Friday; they are on call for emergencies during other hours, on U.S. holidays, and on weekends. </p> <p>&nbsp;</p> <h4>Using encryption</h4> <p>We strongly urge you to encrypt sensitive information sent by email. Our public PGP key is available from </p> <p>&nbsp;</p><ul class="articlelist"><p><a href="https://www.cert.org/CERT_PGP.key" target="_blank">http://www.cert.org/CERT_PGP.key</a> </p> </ul><p>If you prefer to use DES, please call the CERT hotline for more information. </p> <p>&nbsp;</p> <h4>Getting security information</h4> <p>CERT publications and other security information are available from our web site </p> <p>&nbsp;</p><ul class="articlelist"><p><a href="https://www.cert.org/" target="_blank">http://www.cert.org/</a> </p> </ul><p>To be added to our mailing list for advisories and bulletins, send email to <a href="mailto:[email protected]">[email protected]</a> and include <tt>SUBSCRIBE your-email-address</tt> in the subject of your message. </p> <p>Copyright 2000 Carnegie Mellon University.<br> Conditions for use, disclaimers, and sponsorship information can be found in </p> <p>&nbsp;</p><ul class="articlelist"><p><a href="https://www.cert.org/legal_stuff.html" target="_blank">http://www.cert.org/legal_stuff.html</a> </p> </ul><p>* "CERT" and "CERT Coordination Center" are registered in the U.S. Patent and Trademark Office. </p> <hr noshade width="100%"><p>NO WARRANTY<br><b>Any material furnished by Carnegie Mellon University and the Software Engineering Institute is furnished on an "as is" basis. Carnegie Mellon University makes no warranties of any kind, either expressed or implied as to any matter including, but not limited to, warranty of fitness for a particular purpose or merchantability, exclusivity or results obtained from use of the material. Carnegie Mellon University does not make any warranty of any kind with respect to freedom from patent, trademark, or copyright infringement.</b> </p> <hr><p>Revision History<br><br> February 2, 2000: Initial release.<br> February 3, 2000: Clarifications on impact of Java applets. New vendor information.&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; </p><dl><dd></dd></dl><strong>CREDITS</strong><br><small>Reported by CERT</small> </form> </td></tr></tbody></table></body>

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like