set of web security test cases and a toolkit to construct new ones

Webseclab

Build Status GoDoc

Webseclab contains a sample set of web security test cases and a toolkit to construct new ones. It can be used for testing security scanners, to replicate or reconstruct issues, or to help with investigations or discussions of particular types of web security bugs.

Install

If you don't have Go installed yet, grab the latest stable version from https://golang.org/dl/ and install following instructions on https://golang.org/doc/install.

Set GOPATH environment variable as described in http://golang.org/doc/code.html#GOPATH - for example export GOPATH=$HOME/go. (You may wish to add $GOPATH/go/bin to your PATH.) Then run:

$ go get github.com/yahoo/webseclab/...

Run

$GOPATH/bin/webseclab [-http=:8080]

or simply webseclab if $GOPATH/bin is in your PATH.

Run webseclab -help to view the options.

Webseclab Tests

In all tests, excepts where specially mentioned, the attack input is assumed to be placed in the "in" CGI variable: <url>?in=<attack_string>. See the index page for PoEs (proof of exploits).

Reflected XSS

  • xss/reflect/raw1 - echoes "raw" tags = literal '<' and '>' sent by the browser (IE-related). Can be tested with curl (Firefox/Chrome/Safari escape tag characters when sending to the server)

  • xss/reflect/basic - echo of unfiltered input in a "normal" HTML context (not between tags, etc.). The example shows the minimal Webseclab template consisting of just {{.In}} placeholder. PoE: /xss/reflect/basic?in=<script>alert(/HACKED/)</script> or /xss/reflect/basic?in=<img src=foo onerror=alert(12345)>

  • xss/reflect/basic_in_tag - echo of unfiltered input inside of a "regular" HTML tag (<B>) PoE: /xss/reflect/basic_in_tag?in=<script>alert(/HACKED/)</script> or /xss/reflect/basic_in_tag?in=<img src=foo onerror=alert(12345)>

  • xss/reflect/full1 - Javascript injection with closed quotes and a script tag echoed

  • xss/reflect/post1 - same as above with injection via POST "in" form field (only POST method is allowed). xss/reflect/post1_splash can be used as a starting page with the action URL of xss/reflect/post1.

  • xss/reflect/doubq1 - injection of double-escaped tags such as: xss/reflect/doubq1?in=%253Cscript%253Ealert%28%252FXSS%252F%29%253C%252Fscript%253E

  • xss/reflect/rs1 - Response-Splitting attack, injection of %0D%0A%0D%0A which echoed unescaped in the header turning it into the response body. PoE: /xss/reflect/rs1?in=xyz%0D%0A%0D%0A<script>alert(/BAD_NEWS/)</script>

  • xss/reflect/onmouseover* - XSS due to attribute injections in tags (such as onmouseover handler)

  • xss/reflect/oneclick1 - JS injection into JS executable context (unquoted input) - so-called "oneclick XSS".

  • xss/reflect/refer - the Referer header echoed. You can set up a page pointing to <WEBSECLAB_URL>/misc/webseclab_refer.html?%3Cscript%3Ealert%28789%29%3C/script%3E as a starting point to set the referer.

  • xss/reflect/js* - different cases of injection into Javascript blocks, see the index page for more details

  • xss/reflect/enc2 - double quotes escaped with a backslash but backslash itself is not. Exploitable injection into Javascript strings.

  • xss/reflect/backslash1?in=xyz - Unicode escape sequences like \u0022 unescaped by the server to became the corresponding (dangerous) character (double quotes).

DOM XSS

  • xss/dom/domwrite?in=foo - passing the unescaped document.location value to document.write(), PoE (Firefox): /xss/dom/domwrite?in=%3Cimg%20src=foo%20onerror=alert%28123%29%3E

  • xss/dom/domwrite_hash?#whatever - passing the unescaped document.hash value to document.write(). PoE (Firefox): /xss/dom/domwrite_hash?#in=%3Cimg%20src=foo%20onerror=alert%281246%29%3E

  • xss/dom/domwrite_hash_urlstyle#/foo/bar?in=whatever - passing the unescaped document.hash URL-style value to document.write(). PoE (Firefox): /xss/dom/domwrite_hash_urlstyle#/foo/bar?in=%3Cimg%20src=foo%20onerror=alert%281246%29%3E

  • xss/dom/yuinode_hash?#in=xyz - passing the hash value to YUI's setHTML function. PoE (Chrome/Firefox): /xss/dom/yuinode_hash?#in=xyz">/xss/dom/yuinode_hash?#in=xyz - DOM XSS using YUI (location.hash)

  • xss/dom/yuinode_hash_urlstyle/#/foo/bar?in=xyz - passing the URL-style hash value to YUI's setHTML function. PoE (Chrome/Firefox): /xss/dom/yuinode_hash_urlstyle/#/foo/bar?in=xyz">/xss/dom/yuinode_hash_urlstyle/#/foo/bar?in=xyz - DOM XSS using YUI (location.hash, URL-style value)

  • xss/dom/yuinode_hash_unencoded?#in=xyz - passing the unencoded hash value to YUI's setHTML function. PoE (Firefox / Chrome): /xss/dom/yuinode_hash?#in=xyz">/xss/dom/yuinode_hash?#in=xyz - DOM XSS using YUI (decoded location.hash)

Modifying Tests

When modifying, adding or deleting any tests, you need to rerun go generate.

For most of the tests, you need to add a template that contains the "moustache" with {{.In}}.

To add a new test where input is echoed unfiltered, just drop an html template under templates directory (for example templates/xss/newfile) with the template containing the {{.In}} placeholder.

To add a new "filter-based" case, add a template as above and add a mapping of the corresponding entrypoint (such as /xss/newfile ) to the map in the filterMap function in custom.go. For example:
mp["/xss/reflect/newtest"] = []filter{TagsOff, SingleQuotesOff, GreaterThanOff}
for a test with the corresponding input filtering. See filters.go for the list of the available filters.

To add a new fully custom testcase, add a template (if needed), add a mapping of the entrypoint to the handling function to CustomMap in custom.go and implement the custom function with the signature: func(http.ResponseWriter, *http.Request). For example, for a test case with XSS injection through the Morse code, you could add:
mp["/xss/reflect/morse"] = XssUnsafeMorse. See entrypoints and implementing functions in CustomMap in custom.go.

Owner
Yahoo
Yahoo is a Verizon Media brand. This organization is the home to many of the active open source projects published by engineers at Yahoo and Verizon Media.
Yahoo
Comments
  • XSS not being triggered in modern browsers

    XSS not being triggered in modern browsers

    Browsers nowadays automatically escape URLs, leaving a lot of XSS cases unexploitable. For example this:

    http://localhost:8080/xss/dom/domwrite?in=abckk<xss>
    

    ...will not be exploitable in Firefox 35.0.1, as it'll be automatically converted to:

    http://localhost:8080/xss/dom/domwrite?in=abckk%3Cxss%3E
    

    Same goes for any client which properly follows the RFC specifications.

    Maybe URI-decode that sort of data prior to using it in XSS demo cases?

  • URL query style location.hash parameters

    URL query style location.hash parameters

    I think it'd be a good idea to convert this:

    http://127.0.0.2:8080/xss/dom/yuinode_hash?#in=xyz
    

    to:

    http://127.0.0.2:8080/xss/dom/yuinode_hash#/?in=xyz
    

    It's a small change but the current convention seems to be to emulate the usual URL style in the hash.

    Example:

    http://testhtml5.vulnweb.com/#/redir?url=http://www.thoughtcrime.org/blog/gpg-and-me/
    

    Also, scanners usually play ball with the 2nd style automatically, otherwise folks trying them against webseclab will need to provide further configuration.

    What do you think?

  • add yuinode_hash_urlstyle DOMXSS test (issue #9)

    add yuinode_hash_urlstyle DOMXSS test (issue #9)

    yuinode_hash_urlstyle added (different URL but with the same script handling as in yuinode_hash - is it ok?), also fixed some of the documentation snippets (yuinode_has PoE works in Chrome)

    PoE: http://127.0.0.1:8080/xss/dom/yuinode_hash_urlstyle#/foo/bar?in=<img src=foo onerror=alert(149)>

    Interestingly, the PoE above works in Chrome and Opera but not in Safari - we should refresh and update the domxsswiki to have an up-to-date doc on all the browser-specific input handling diffs.

  • fix golint-flagged issues

    fix golint-flagged issues

    API changed (incompatibly) - https://godoc.org/github.com/yahoo/webseclab does not show any packages importing webseclab; if used as a library, it is expected that the code would be vendored.

  • Standalone executable, binpacking of templates

    Standalone executable, binpacking of templates

    Templates packed into the binary to avoid relying on the presence of the source tree with template files, GOPATH being defined etc. This will enable to distribute the compiled or cross-compile binary independently and users will not need to install Go to be able to run webseclab.

    go generate needs to be run when templates are added or modified.

    Additionally added a Go runtime copyright notice with the link to golang.org/LICENSE and a "insecure software, be careful!" notice.

    Fixes #19

  • textarea_fp is exploitable

    textarea_fp is exploitable

    The following fires an alert:

    http://10.89.11.247:8080/xss/reflect/textarea1_fp?in=%3C%2Ftextarea%3E%3Cscript%3Ealert%28/XSS/%29%3B%3C%2Fscript%3E%3Ctextarea%3E
    
  • onmouseover_fp is exploitable (in Firefox)

    onmouseover_fp is exploitable (in Firefox)

    http://127.0.0.1:8088/xss/reflect/onmouseover_fp?in=bar%22+onmouseover%3D%22alert%28123%29 produces the source:

    FORM> Homepage: <input value="bar"onmouseover="alert(123)" name="in" size="40">

    which fires XSS in Firefox. Need to neutralize the injection.

  • use canonical uppercase spelling of IP

    use canonical uppercase spelling of IP

    abbreviations like "IP" should be in upper-case as in "fooIPBar" or "FooIPBar".

    Similar cases in the standard library: http://golang.org/pkg/net/#IP http://golang.org/pkg/net/?m=all#cgoLookupIP

  • /xss/reflect/onmouseover_fp is exploitable

    /xss/reflect/onmouseover_fp is exploitable

    Should be a False Positive but currently exploitable.

    PoE: http://127.0.0.1:8080/xss/reflect/onmouseover_fp?in=ch01xabcD%22%20onmouseover=alert%28123%29+x=%22

  • add noindex option and basic_in_tag test

    add noindex option and basic_in_tag test

    -noindex helps in cases where you want the scanner to focus only on the URL you give - but the scanner is clever enough to discover other URLs from the Webseclab root ("/" or "/index.html"), as is the case with ZAP.

    basic_in_tag test is a simplistic test echoing unfiltered path (including cgi parameters) inside of a <B> tag (just in case the scanner treats such injections differently to those outside of the tags)

  • binddata - include assets (templates) into the executable

    binddata - include assets (templates) into the executable

    For ease of installation, distribution and operation, it could be an advantage to include the assets (in particular, the HTML templates) into the webseclab binary so that you would not need to distribute them alongside the executable and have issues with finding them at the start time.

Related tags
Web-Security-Academy - Web Security Academy, developed in GO

Web-Security-Academy - Web Security Academy, developed in GO

Feb 23, 2022
Gryffin is a large scale web security scanning platform.

Gryffin (beta) Gryffin is a large scale web security scanning platform. It is not yet another scanner. It was written to solve two specific problems w

Dec 27, 2022
CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security signals for open source package versions.
CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security signals for open source package versions.

depsdev CLI client (and Golang module) for deps.dev API. Free access to dependencies, licenses, advisories, and other critical health and security sig

May 11, 2023
A FreeSWITCH specific scanning and exploitation toolkit for CVE-2021-37624 and CVE-2021-41157.

PewSWITCH A FreeSWITCH specific scanning and exploitation toolkit for CVE-2021-37624 and CVE-2021-41157. Related blog: https://0xinfection.github.io/p

Nov 2, 2022
Shfz - Scenario-based fuzzing test execution tool for web applications
Shfz - Scenario-based fuzzing test execution tool for web applications

shfz A scenario-based web application fuzzng tool that supports fuzz generation

Nov 9, 2022
Dec 28, 2022
Tracee: Linux Runtime Security and Forensics using eBPF
Tracee: Linux Runtime Security and Forensics using eBPF

Tracee is a Runtime Security and forensics tool for Linux. It is using Linux eBPF technology to trace your system and applications at runtime, and analyze collected events to detect suspicious behavioral patterns.

Jan 5, 2023
A scalable overlay networking tool with a focus on performance, simplicity and security

What is Nebula? Nebula is a scalable overlay networking tool with a focus on performance, simplicity and security. It lets you seamlessly connect comp

Dec 29, 2022
GoPhish by default tips your hand to defenders and security solutions. T

GoPhish by default tips your hand to defenders and security solutions. The container here strips those indicators and makes other changes to hopefully evade detection during operations.

Jan 4, 2023
Go binary that finds .EXEs and .DLLs on the system that don't have security controls enabled

Go Hunt Weak PEs Go binary that finds .EXEs and .DLLs on the system that don't have security controls enabled (ASLR, DEP, CFG etc). Usage $ ./go-hunt-

Oct 28, 2021
Analyse binaries for missing security features, information disclosure and more.
Analyse binaries for missing security features, information disclosure and more.

extrude Analyse binaries for missing security features, information disclosure and more. ?? Extrude is in the early stages of development, and current

Dec 16, 2022
QR secrets is a cryptographically secure mechanism to store secret data with the highest levels of security and store it on physical paper.
QR secrets is a cryptographically secure mechanism to store secret data with the highest levels of security and store it on physical paper.

QR Secrets QR secrets is a cryptographically secure mechanism to store secret data with the highest levels of security. Incorporating; AES256-GCM-HKDF

Jan 12, 2022
HTTP middleware for Go that facilitates some quick security wins.

Secure Secure is an HTTP middleware for Go that facilitates some quick security wins. It's a standard net/http Handler, and can be used with many fram

Jan 3, 2023
PHP security vulnerabilities checker

Local PHP Security Checker The Local PHP Security Checker is a command line tool that checks if your PHP application depends on PHP packages with know

Jan 3, 2023
Sqreen's Application Security Management for the Go language
Sqreen's Application Security Management for the Go language

Sqreen's Application Security Management for Go After performance monitoring (APM), error and log monitoring it’s time to add a security component int

Dec 27, 2022
How to systematically secure anything: a repository about security engineering
How to systematically secure anything: a repository about security engineering

How to Secure Anything Security engineering is the discipline of building secure systems. Its lessons are not just applicable to computer security. In

Jan 5, 2023
Convenience of containers, security of virtual machines

Convenience of containers, security of virtual machines With firebuild, you can build and deploy secure VMs directly from Dockerfiles and Docker image

Dec 28, 2022
MQTT安全测试工具 (MQTT Security Tools)
MQTT安全测试工具 (MQTT Security Tools)

███╗ ███╗ ██████╗ ████████╗████████╗███████╗ ████╗ ████║██╔═══██╗╚══██╔══╝╚══██╔══╝██╔════╝ ██╔████╔██║██║ ██║ ██║ ██║ ███████╗ ██║╚██╔╝█

Dec 21, 2022
gosec - Golang Security Checker
 gosec - Golang Security Checker

Inspects source code for security problems by scanning the Go AST.

Jan 2, 2023