GithubHelp home page GithubHelp logo

esapi / owasp-esapi-js Goto Github PK

View Code? Open in Web Editor NEW
98.0 17.0 32.0 8.38 MB

An UNMAINTAINTED project originally exported from code.google.com/p/owasp-esapi-js. This project is deprecated. See the README.md for further details and possible alternatives.

License: Other

JavaScript 99.37% HTML 0.63%

owasp-esapi-js's People

Contributors

kwwall avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

owasp-esapi-js's Issues

owasp-esapi-js needs dependency update

@dsmorse and @chrisisbeef -- There is a critical CVE related to bower on this project. (See the GitHub Dependabot alert for details or drop me an email.) It's been there for a while in fact.

I think all I need to do to update this is to change the version of bower to version 1.8.8 (or later) in package.json, but I have no idea of how to "build" this or more importantly, to test this. This sort of thing makes OWASP look really bad and unlike esapi4java (i.e, esapi-java-legacy) I have no idea of how to determine whether or not the bower CVE leads to an exploitable path via ESAPI for JavaScript. But if we don't get this fixed, I'm tempted to just delete the repository or make it with a huge "Do NOT use!" warning on the README.md file. So please help me get this fixed.

If there were decent build / test instructions, I'd be glad to help. I've installed both 'npm' and 'grunt-cli' packages, but 'grunt build' and 'grunt test' both result in errors so I am at a loss as to how to proceed.

Please review your coding style

Please review your coding style:
destructivity, security, performance and JavaScript language quality
of your own code.

Please see this for short teaser;-)
http://ainthek.blogspot.com/2010/08/interesting-project-owasp-esapi-js.html

Sorry to post directly here, but none of you have public mail here....


Original issue reported on code.google.com by [email protected] on 2 Aug 2010 at 2:20

Unresponsive script issue in firefox browser upon referencing esapi related libraries

What steps will reproduce the problem?
1. Reference esapi related libraries in the existing html.
   <script type="text/javascript" language="JavaScript" src="../esapi4js/lib/log4js.js"></script>
<script type="text/javascript" language="JavaScript" 
src="../esapi4js/esapi.js"></script>
<script type="text/javascript" language="JavaScript" 
src="../esapi4js/resources/i18n/ESAPI_Standard_en_US.properties.js"></script>
<script type="text/javascript" language="JavaScript" 
src="../esapi4js/resources/Base.esapi.properties.js">

2. Open the html file using firefox browser.
3. The browser hangs for sometime and displays the following message: 
"Unresponsive script: A script on this page might be busy, or may have stopped 
responding"
4. If the esapi references are removed, the browser launches fine.

What is the expected output? What do you see instead?
The expected output is that the browser should launch fine after integration 
with esapi. Instead the script becomes unresponsive.

What version of the product are you using? On what operating system?
Browser: Mozilla Firefox 22.0
OS: Windows 7


Please provide any additional information below.

Original issue reported on code.google.com by [email protected] on 30 Jul 2013 at 5:59

Canonicalize ("cananicalize") is spelled wrong in DefaultEncoder.js

What is the expected output? What do you see instead?
The canonicalize method is spelled wrong. It appears as 
"cananicalize: function(sInput, bStrict)"

What version of the product are you using? On what operating system?
This appears in trunk and in version 0.1.3
Link to file:
http://code.google.com/p/owasp-esapi-js/source/browse/trunk/src/main/javascript/
org/owasp/esapi/reference/encoding/DefaultEncoder.js

This needs to be corrected as usage of this library increases. Worst case, 
leave it spelled incorrectly and have it call the one that is spelled correctly.

Original issue reported on code.google.com by [email protected] on 15 Nov 2012 at 5:17

Having issues with URL validation

I am using the below code to check the passing URL is valid or not.
Its giving true irrespective of the input I pass.Please let me know ,I am doing 
anything wrong.Attached in the jsp file contains the code.
What steps will reproduce the problem?
1. Please use the JSP file attached herewith to reproduce the issue.
2.
3.

What is the expected output? What do you see instead?
true or false depends on the input gets passed.

What version of the product are you using? On what operating system?
esapi4j-0.1.3 ,Windows 7 64 bit


Please provide any additional information below.
For Ex : I am passing input as <script>alert(1);</script>. The isValidInput fn 
returning true 

Original issue reported on code.google.com by [email protected] on 20 Jan 2015 at 11:41

Attachments:

Extend XMLHttpRequest API to turn off HTML5 Cross Origin Request by default

The XHR API is capable of making Cross domain calls now thanks to HTML5. There 
are applications that include user controlled data as the request URL in 
XHR.open().

This was assumed to be safe because this value could only be set to file hosted 
on the same domain. But with HTML5 this value can be set to file on an attacker 
controlled domain.
Real life example on touch.facebook.com: http://m-austin.com/blog/?p=19

Server-side ESAPI provides secure equivalent of the request and response 
object. Similarly ESAPI4JS can provide a secure equivalent of XMLHttpRequest 
object by turning off support of COR by default(a little similar to this - 
http://myappsecurity.blogspot.com/2007/01/ajax-sniffer-prrof-of-concept.html).

A new property can be added to the extended XHR API called 'cor'. Only if this 
flag is set would Cross Domain Requests be allowed. As explained towards the 
end of this post - 
http://blog.andlabs.org/2010/08/xssing-client-side-dynamic-html.html

Ideally this change must be made to the underlying API itself but until then 
ESAPI4JS can fill the gap I guess.

Original issue reported on code.google.com by [email protected] on 24 Aug 2010 at 7:10

decodeForHTML returns same character for &Ugrave; and &ugrave;

What steps will reproduce the problem?
1. decodeForHTML returns same character for &Ugrave; and &ugrave;  This is true 
for all named entities with upper/lower case versions. 

What is the expected output? What do you see instead?

&Ugrave; should return upper case U with accent, and &ugrave; should return 
lower case u with accent.

What version of the product are you using? On what operating system?

Latest version on Linux.

Please provide any additional information below.

In HTMLEntityCodec.js, you should probably not do a case insensitive look-up at 
the end of the getNamedEntity function.

Thanks!

Original issue reported on code.google.com by [email protected] on 5 Aug 2012 at 9:19

isValidInteger validator always return true

The following call returns true instead of false:

 esapi.validator().isValidInteger("Integer", 500, false, 1, 99);

The problem comes from:

  • DefaultValidator.isValidInteger calls DefaultValidator.getValidInteger
  • DefaultValidator.getValidInteger calls BaseValidationRule.getValid
  • getValid calls getValidInput, but all validation exceptions are catched to call this.sanitize which returns the input instead of false, hence isValidInteger always return true

Security Controls for HTML5 Drag and Drop Events

Implement a security control for ensuring that only intended documents have
access to the DataTransferObject during a drag operation by providing a
wrapped implementation. For information see the following link.

http://www.w3.org/TR/html5/editing.html#security-risks-in-the-drag-and-drop-mode
l

In comments, discuss possible mitigation of MiTM and XSS risks associated
with the new HTML Drag and Drop functionality.

Original issue reported on code.google.com by chrisisbeef on 29 Apr 2010 at 2:36

encodeForURL doesn't URL encode certain special characters

What steps will reproduce the problem?
1.  encodeForURL doesn't URL encode certain special characters such as * @ - _ 
+ . /

What is the expected output? What do you see instead?
The above characters should be URL encoded.


What version of the product are you using? On what operating system?
Latest version on Linux.

Please provide any additional information below.

Looks like in DefaultEncoder.js, the encodeForURL/decodeForURL it is calling 
escape()/unescape().  It should probably call 
encodeURIComponent()/decodeURIComponent() instead.

Original issue reported on code.google.com by [email protected] on 7 Sep 2012 at 5:27

esapi.js encodeForHTML then decodeForHTML does not give the original input for ( ) ; /

Hi All,

I must be doing something wrong ? I am using esapi.js to encode and then decode a strong containing a piece of script that could be used in a primitive XSS attack. e.g.

Code Snippet:
name = $ESAPI.encoder().encodeForHTML( name );
$ESAPI.encoder().decodeForHTML(name);

Input: Message <script>alert("JS XSS ARRRHHH")</script> 1
Encoded: Message &lt;script&gt;alert("JS XSS ARRRHHH")&lt;/script&gt; 1
Decoded: Message <script>alert40"JS XSS ARRRHHH"41<47script> 1

Any ideas - this seems very basic to be broken, so im assuming user error ?

Thanks in advance,

Gareth

typo in esapi.js

in esapi.js, line 1113
entityToCharacterMap["&image"]           = "8365";  /* 8465 : black-letter 
capital i */

should be changed to 

entityToCharacterMap["&image"]           = "8465";  /* 8465 : black-letter 
capital i */

8365->8465


Original issue reported on code.google.com by [email protected] on 30 Mar 2012 at 9:12

ESAPI Wrapper for Importing External Scripts

Create an AjaxLoader mechanism with security controls for securely loading
and executing scripts dynamically.

Original issue reported on code.google.com by chrisisbeef on 29 Apr 2010 at 5:05

JQuery Plugin Adapter

Drew this is a placeholder for the ESAPI4JS JQuery Plugin.

Original issue reported on code.google.com by chrisisbeef on 29 Apr 2010 at 4:21

decodeForHTML does not give the desire output.

What steps will reproduce the problem?
1. Initialize org.owasp.esapi.ESAPI.initialize();
2. see the out put of 
$ESAPI.encoder().encodeForHTML("<script>alert('123');</script>");
output:- 
"&lt;script&gt;alert&#x28;&#x27;123&#x27;&#x29;&#x3b;&lt;&#x2f;script&gt;"
3. See the out of decodeForHTML 
$ESAPI.encoder().decodeForHTML("&lt;script&gt;alert&#x28;&#x27;123&#x27;&#x29;&#
x3b;&lt;&#x2f;script&gt;");
output:- "<script>alert4039123394159<47script>"

What is the expected output? What do you see instead?
Actual output:- "<script>alert4039123394159<47script>"
Expected :- "<script>alert('123');</script>"

What version of the product are you using? On what operating system?
Version:- esapi4js-0.1.3
OS:- Mac

Please provide any additional information below.
I have fix this issue, 
Solution:- In org.owasp.esapi.codecs.HTMLEntityCodec, the function parseNumber 
and parseHex returning number directly(return parseInt(out);). it should return 
char code(return String.fromCharCode(parseInt(out));).
Below are the function i have modified (see //Commented to fix esapi bug)

var parseNumber = function(input) {
        var out = '';
        while (input.hasNext()) {
            var c = input.peek();
            if (c.match(/[0-9]/)) {
                out += c;
                input.next();
            } else if (c == ';') {
                input.next();
                break;
            } else {
                break;
            }
        }

        try {
            return String.fromCharCode(parseInt(out));
            //Commented to fix esapi bug
            //return parseInt(out);
        } catch (e) {
            return null;
        }
    };

    var parseHex = function(input) {
        var out = '';
        while (input.hasNext()) {
            var c = input.peek();
            if (c.match(/[0-9A-Fa-f]/)) {
                out += c;
                input.next();
            } else if (c == ';') {
                input.next();
                break;
            } else {
                break;
            }
        }
        try {
            return String.fromCharCode(parseInt(out, 16));
            //Commented to fix esapi bug
            //return parseInt(out, 16);
        } catch (e) {
            return null;
        }
    };

I have fixed this issue in esapi.js and using it for my project.

Thanks
Bikesh Kumar

Original issue reported on code.google.com by [email protected] on 19 Mar 2013 at 9:35

getValidInput always throwing an exception

What steps will reproduce the problem?
1. $ESAPI.validator().getValidInput("test", "[email protected]", "Email", 50, 
true);
2.
3.

What is the expected output? What do you see instead?
Expected : "[email protected]"
seen : null

What version of the product are you using? On what operating system?
esapi4js-0.1.3

Please provide any additional information below.
a couple of issues I encountered while trying to debug:
checkEmpty function returns null or nothing. as a result the following line in 
getValidInput always returns null.


            if ( checkEmpty( sContext, sInput ) == null ) {
                return null;
            }

if I fix this, I still run into an exception in checkWhitelist. Seems like it 
is throwing an error IF the input matches the expression. 

if(sInput.match(p)) {
...
}

should it be if(!sInput.match(p)){}

?

Original issue reported on code.google.com by [email protected] on 9 Sep 2013 at 4:38

ECMAScript Security

if the Object.lock and/or Object.seal methods are implemented, use them to
lock down the current ESAPI implementation.

Original issue reported on code.google.com by chrisisbeef on 29 Apr 2010 at 5:07

for...in function not working when i include the esapi.js file

When i include the esapi.js file and use the for..in loop in my js function, it automatically adds the each parameter and calls the function(fIterator) which leads to error.
Check the screenshot below. When i define a variable and run it in for...in loop, the other functions in esapi.js are also called.
screenshot from 2017-05-23 19 54 36

Getting started guide JS sample doesn't work

What steps will reproduce the problem?
Follow the steps in the getting started guide and copy the JS code sample as is

What is the expected output? 
ESAPI methods work.

What do you see instead?
JS Errors

What version of the product are you using? On what operating system?
ESAPI4JS 1.3  on Firefox 23 linux 32 bit.

Please provide any additional information below.
The order that the JS libraries load is significant.  The sample code in the 
getting started guide should be:

<!-- esapi4js dependencies -->
    <script type="text/javascript" language="JavaScript" src="scripts/esapi4js/lib/log4js.js"></script>
    <!-- esapi4js core -->
    <script type="text/javascript" language="JavaScript" src="scripts/esapi4js/esapi.js"></script>
    <!-- esapi4js i18n resources -->
    <script type="text/javascript" language="JavaScript" src="scripts/esapi4js/resources/i18n/ESAPI_Standard_en_US.properties.js"></script>
    <!-- esapi4js configuration -->
    <script type="text/javascript" language="JavaScript" src="scripts/esapi4js/resources/Base.esapi.properties.js"></script>




Original issue reported on code.google.com by [email protected] on 28 Aug 2013 at 7:23

Variable conflict

image
there is a variable named "$",it always conflict with other variables.

IFrame Sandboxing Cross-Browser/Pre HTML5

Investigate a way to implement a factory mechanism to create sandboxed
iframes to simplify the problem of loading potentially untrusted content
into a page (read widgets, microapps, etc.)

Ideally this would be accessed via the Locator like
<script type="text/javascript">
var untrustedWidget = false;
with( $ESAPI.domUtilities() ) {
   untrustedWidget = this.contentFactory.createIFrame({
      id: 'untrusted-widget',
      src: 'http://www.untrusted.com/widget',
      sandboxAttributes: [ 
         this.Sandbox.ALLOW_SAME_ORIGIN 
      ]
   });
};
$ESAPI.select( 'untrusted-widget-container' ).appendChild( untrustedWidget );
</script>

The implementation of the createIFrame method would use the sandbox
attribute of IFrame if supported by the user-agent, and if not create a
IFrame Javascript sandbox using a third party library or by preloading the
content of the page, and wrapping any javascript executed in the frame in
the context of a with() block that provides a limited subset of the
javascript API (whitelist and blacklist) 

There is a great deal of documentation around IFrame Sandboxing in the
HTML5 Specification 

http://dev.w3.org/html5/spec/Overview.html#attr-iframe-sandbox

Original issue reported on code.google.com by chrisisbeef on 29 Apr 2010 at 4:20

Broken links in testcases

esapi4js-0.1.3\src\test\javascript\testCore.html

references dist directory which is not part of downloaded package ! 

Original issue reported on code.google.com by [email protected] on 4 Aug 2010 at 9:28

esapi js validation not working

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>

<!-- esapi4js dependencies -->
 <script type="text/javascript" language="JavaScript" src="http://localhost/esapi/esapi4js/lib/log4js.js"></script>
 <!-- esapi4js core -->
 <script type="text/javascript" language="JavaScript" src="http://localhost/esapi/esapi4js/esapi.js"></script>
 <!-- esapi4js i18n resources -->
 <script type="text/javascript" language="JavaScript" src="http://localhost/esapi/esapi4js/resources/i18n/ESAPI_Standard_en_US.properties.js"></script>
 <!-- esapi4js configuration -->
 <script type="text/javascript" language="JavaScript" src="http://localhost/esapi/esapi4js/resources/Base.esapi.properties.js"></script>

 <script type="text/javascript" language="JavaScript">
 Base.esapi.properties.logging['ApplicationLogger'] = {
 Level: org.owasp.esapi.Logger.ALL,
 Appenders: [ new Log4js.ConsoleAppender() ],
 LogUrl: true,
 LogApplicationName: true,
 EncodingRequired: true
 };

 Base.esapi.properties.application.Name = "My Application v1.0";
 org.owasp.esapi.ESAPI.initialize();
 $ESAPI.logger('ApplicationLogger').info(org.owasp.esapi.Logger.EventType.
 EVENT_SUCCESS, 'This is a test message');
 document.writeln( $ESAPI.encoder().encodeForHTML("<a href=\"http://owaspesapi-js.googlecode.com\">Check out esapi4js</a>"));


 var validateCreditCard = function() {
 alert($ESAPI.validator().isValidCreditCard($('CreditCard').value));
  //allow.html5.validation: true;
 //return $ESAPI.validator().isValidCreditCard( $('CreditCard').value);
 }
  </script>

</head>
<body>
<form name="user-profile-form" method="post" id="user-profile-form" action="" 
onsubmit="return validateCreditCard();" >
<span>credit Card: </span><input name="CreditCard" type="text" 
class="inputarea" id="CreditCard" maxlength="100"/>
<input  type="submit" name="submit" id="submit"  value="submit"/>
</form>
</body>
</html>



This code not working. Pls post your how to change the working code.


Original issue reported on code.google.com by [email protected] on 24 Aug 2012 at 4:43

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.