<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Scott Gerlach</title>
    <description>The latest articles on DEV Community by Scott Gerlach (@sgerlach).</description>
    <link>https://dev.to/sgerlach</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F369150%2F42d2c74a-aaec-47bf-ac8c-97ef90e84058.png</url>
      <title>DEV Community: Scott Gerlach</title>
      <link>https://dev.to/sgerlach</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sgerlach"/>
    <language>en</language>
    <item>
      <title>Using StackHawk in GitLab - Know Before You Go (Live)</title>
      <dc:creator>Scott Gerlach</dc:creator>
      <pubDate>Tue, 21 Apr 2020 17:45:31 +0000</pubDate>
      <link>https://dev.to/sgerlach/using-stackhawk-in-gitlab-know-before-you-go-live-1nhp</link>
      <guid>https://dev.to/sgerlach/using-stackhawk-in-gitlab-know-before-you-go-live-1nhp</guid>
      <description>&lt;p&gt;The earlier you find application bugs, the cheaper it is to fix them. That’s one of the reasons so many organizations have adopted Test Driven Development (TDD). TDD enables Developers to more accurately identify if the code you are about to commit is going to break and not pass the tests you’ve instrumented in CI/CD. Analogous to the TDD process, we believe in automating application security testing. That’s why we created StackHawk!&lt;/p&gt;

&lt;h2&gt;
  
  
  Check Out How it Works
&lt;/h2&gt;

&lt;p&gt;This post demonstrates how to leverage StackHawk to automate testing for AppSec bugs in your CI/CD pipeline. We’ll walk through:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;An Example App, “Vulny Django”, used for testing StackHawk&lt;/li&gt;
&lt;li&gt;How I Dockerized my Django App &lt;/li&gt;
&lt;li&gt;Building and testing my app in GitLab&lt;/li&gt;
&lt;li&gt;Finding application security bugs in the pipeline with StackHawk&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;em&gt;Note: StackHawk is a dynamic application security testing (DAST) scanner that actively tests the code that developers write for security bugs&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Example App: Polling with Django + Local StackHawk Scan
&lt;/h2&gt;

&lt;p&gt;I took the &lt;a href="https://docs.djangoproject.com/en/3.0/intro/tutorial01/"&gt;Django tutorial&lt;/a&gt; on making a polls application and modified it into a project I call &lt;a href="https://github.com/stackhawk/vuln_django_play"&gt;Vulny Django&lt;/a&gt; to test StackHawk. I’m not the best coder, so as I created the app, I wanted to run the tests that we built in with the tutorial alongside the StackHawk DAST scanner. Running StackHawk locally allows me to ensure that I have not introduced any AppSec bugs as I build.&lt;/p&gt;

&lt;p&gt;The StackHawk scanning capability is configured via a &lt;a href="https://docs.stackhawk.com/hawkscan/getting-started.html#configuration"&gt;yaml file&lt;/a&gt; that describes how to scan your application. In this example app, we have a pretty simple &lt;a href="https://github.com/stackhawk/vuln_django_play/blob/develop/stackhawk.yml"&gt;StackHawk config&lt;/a&gt; to scan locally, as we mostly have to instrument how to log in to the admin page and a few URLs to exclude. With this configuration, I can easily scan my Polls app and the admin interface from my local laptop using the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;vulny_django_play/ &lt;span class="nv"&gt;$ &lt;/span&gt;docker run &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HAWK_API_KEY&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/hawk:rw &lt;span class="nt"&gt;-it&lt;/span&gt; stackhawk/hawkscan:latest
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This command dynamically scans my running Django app to test it for security issues that can be triaged on the StackHawk platform.&lt;/p&gt;

&lt;h2&gt;
  
  
  Containerizing The Polls App for Testing in Pipeline
&lt;/h2&gt;

&lt;p&gt;I have also dockerized my Django project, because why wouldn’t you!? I want to be able to scan my Django project in &lt;a href="https://about.gitlab.com/stages-devops-lifecycle/"&gt;GitLab’s awesome DevOps platform&lt;/a&gt;. To do that, my application needs to be running somewhere. While I could deploy my app onto a staging site and have HawkScan, the StackHawk scanner, scan it there, I choose the ephemeral route, where everything only lives temporarily while I test it. This allows me to break builds if I find an issue before deploying my app to a place that may be being used for user testing or other things.&lt;/p&gt;

&lt;p&gt;Using docker, I can create a docker network and attach my Django and StackHawk/HawkScan containers to it so they can talk to each other. Doing that looks like this on the command line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;/vulny_django_play/ &lt;span class="nv"&gt;$ &lt;/span&gt;docker network create scan_net

/vulny_django_play/ &lt;span class="nv"&gt;$ &lt;/span&gt;docker run &lt;span class="nt"&gt;--detach&lt;/span&gt; &lt;span class="nt"&gt;-p&lt;/span&gt; 8020:8020 &lt;span class="nt"&gt;--network&lt;/span&gt; scan_net &lt;span class="nt"&gt;--name&lt;/span&gt; vuln-django &lt;span class="nt"&gt;--rm&lt;/span&gt; vuln_django:latest

/vulny_django_play/ &lt;span class="nv"&gt;$ &lt;/span&gt;docker run &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;API_KEY&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;${&lt;/span&gt;&lt;span class="nv"&gt;HAWK_API_KEY&lt;/span&gt;&lt;span class="k"&gt;}&lt;/span&gt; &lt;span class="nt"&gt;-e&lt;/span&gt; &lt;span class="nv"&gt;HOST&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;http://vuln-django &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/hawk:rw &lt;span class="nt"&gt;--tty&lt;/span&gt; &lt;span class="nt"&gt;--network&lt;/span&gt; scan_net stackhawk/hawkscan:latest
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;With these commands, we are:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Building the docker virtual network named ‘scan_net’ &lt;/li&gt;
&lt;li&gt;Running the Django docker image attached to the scan network that we built (

&lt;code&gt;docker build . -t vuln_django:latest&lt;/code&gt;

)&lt;/li&gt;
&lt;li&gt;Running the Django docker image attached to the scan network that we built (

&lt;code&gt;docker build . -t vuln_django:latest&lt;/code&gt;

)&lt;/li&gt;
&lt;li&gt;Running HawkScan while attaching it to the scan_net and overriding the HOST variable in the stackhawk.yml to point at the docker network name of the Django App&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;PSA&lt;/strong&gt;: Django will not let you put underscores in a host name like this &lt;a href="http://vuln_django"&gt;http://vuln_django&lt;/a&gt; because it’s not RFC compliant. If you do that, you will Google search for a while to try and figure out why your app is not working in the docker network only to find that if you change that to a dash, &lt;a href="http://vuln-django"&gt;http://vuln-django&lt;/a&gt;, everything will work fine and you will be embarrassed (actually that last part might just be me).&lt;/p&gt;

&lt;p&gt;Once this is all set, you’ll have two Docker containers talking to each other over a virtual Docker network. This is a perfect time to start working on our GitLab config, since we can do Docker-In-Docker in GitLab.&lt;/p&gt;

&lt;h2&gt;
  
  
  Go Go Gadget GitLab!
&lt;/h2&gt;

&lt;p&gt;GitLab’s DevOps Platform has awesome capabilities. I wanted to wire up my Django project with a platform that could run my tests on PRs when I commit code, or when I want to merge code. GitLab CI/CD made that process pretty easy. They employ a pretty &lt;a href="https://docs.gitlab.com/ee/ci/quick_start/README.html"&gt;simple yml config file&lt;/a&gt; to instrument what the pipeline should look like and do.&lt;/p&gt;

&lt;p&gt;I chose a few tests to run, like flake8 and the migrations and tests I had written to run in the test phase using the python:3.7-buster image. So here we are installing the python library requirements, running flake8, then pre-populating the DB with info and running the test suite.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;test&lt;/span&gt;
  &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;python:3.7-buster&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="c1"&gt;# This configures the test stuff&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;apt-get update -qy&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;apt-get install -y python-dev python-pip&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;pip install -r src/requirements.txt&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;flake8 vuln_django --max-line-length=127&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;cd src&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;python manage.py migrate&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;python manage.py test&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This allows me to make sure my code is healthy before I do anything else, like, say... &lt;/p&gt;

&lt;h2&gt;
  
  
  Testing the Build of The Docker Container
&lt;/h2&gt;

&lt;p&gt;Now it’s time for me to make sure my docker container will successfully build in CI/CD. Here, I need to tell GitLab Runner how to build my image, which is SUPER easy. I tell it I need the docker image and that I would also like the Docker-in-Docker server to make sure that doesn’t introduce any issues with my build:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;docker-build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;build&lt;/span&gt;
  &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docker:19.03.1&lt;/span&gt;
  &lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker:19.03.1-dind&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
   &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker build -t vuln_django:latest .&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This section is pretty straightforward and is similar to building a docker image on your workstation or laptop. This again is just making sure the image will build so that we can get to the good stuff.&lt;/p&gt;

&lt;h2&gt;
  
  
  Scanning My Dockerized Polls App with StackHawk
&lt;/h2&gt;

&lt;p&gt;Now it’s time to scan the dockerized version of my Django app. We know we can scan the application on our workstation in either Virtual Environment or dockerized versions. We know we can make one Docker container talk to another Docker container, so let's tell the GitLab runner how to do that.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;We’ll need the docker image to build upon&lt;/li&gt;
&lt;li&gt;We’ll need the Docker-in-Docker service&lt;/li&gt;
&lt;li&gt;We’ll build the Docker virtual network&lt;/li&gt;
&lt;li&gt;We have to build the Django container and download the StackHawk/HawkScan container&lt;/li&gt;
&lt;li&gt;We’ll have to set the two Docker images to run on the virtual network&lt;/li&gt;
&lt;li&gt;We’ll use a YML override to tell the StackHawk scanner about a new environment and where to find the running application.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;This section of our .gitlab-ci.yml file looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;hawk_scan_execute&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;stage&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;scan&lt;/span&gt;
  &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;docker:19.03.1&lt;/span&gt;
  &lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker:19.03.1-dind&lt;/span&gt;
  &lt;span class="na"&gt;script&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker build -t vuln_django:latest .&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker network create scan_net&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker pull stackhawk/hawkscan:latest&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;docker run --detach -p 8020:8020 --network scan_net --name vuln-django --rm vuln_django:latest&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="pi"&gt;|&lt;/span&gt;
      &lt;span class="s"&gt;docker run --network scan_net --volume $(pwd):/hawk:r --tty --rm \&lt;/span&gt;
        &lt;span class="s"&gt;--env API_KEY="hawk.${HAWK_API_ID}.${HAWK_API_SECRET}" \&lt;/span&gt;
        &lt;span class="s"&gt;--env BRANCH=GitLab:${CI_COMMIT_BRANCH} \&lt;/span&gt;
        &lt;span class="s"&gt;--env NO_COLOR=true \&lt;/span&gt;
        &lt;span class="s"&gt;stackhawk/hawkscan:latest stackhawk.yml stackhawk-gitlab.yml&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Here we used an override yml file and configuration call to tell the scanner some new things. That override file looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;GitLab-CI&lt;/span&gt;
  &lt;span class="c1"&gt;# The url of your application to scan&lt;/span&gt;
  &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://vuln-django:8020&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;We are overriding two settings in the yml file: env and host. The host override is pretty simple, just identifying how the scanner can find the application, so for this configuration we gave it a simple, short name. The env is so I can tell in the StackHawk app which environment ran my scan. I could have other pieces of technology introduce or remove security bugs here, so I want to be able to differentiate. The StackHawk scanner will make the Environment in the Portal GitLab-CI.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Interestingly, We had a customer use this to identify git branch name.. They wanted to know which branch introduced any issues they found. I think this is a really neat way to think about how to group results, but I think I prefer my Environment more loosely grouped, like CI/CD or GitLab.. I will and  I will push that branch name to a Tags feature we will implement later.)&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now I have a configured GitLab Runner for my Django project, with the output looking like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AkjsFt1h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vxf76jdihsp6g4j1r0jh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AkjsFt1h--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/vxf76jdihsp6g4j1r0jh.png" alt="GitLab Runner output"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;And the results in the StackHawk Platform look like this:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--l8WmTjHS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.stackhawk.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-09-at-9.28.10-AM-2048x1412.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--l8WmTjHS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://www.stackhawk.com/wp-content/uploads/2020/04/Screen-Shot-2020-04-09-at-9.28.10-AM-2048x1412.png" alt="StackHawk Platform Results"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Now it’s Easy to Know Before You Go!
&lt;/h2&gt;

&lt;p&gt;As you can see, it’s really easy to implement DAST AppSec Scanning into the GitLab CI/CD pipeline and have the results available in an organized fashion that can help you understand the AppSec bugs that may exist in your application before it goes live. If you’d like to integrate StackHawk into your CI/CD pipeline, sign up for StackHawk &lt;a href="https://www.stackhawk.com/"&gt;Early Access&lt;/a&gt; and we’ll get you started. Also, if you would like to play with &lt;a href="https://github.com/stackhawk/vulny_django_play"&gt;my Django app&lt;/a&gt;, feel free to fork it and use it to test out StackHawk in your CI pipeline.&lt;/p&gt;

</description>
      <category>appsec</category>
      <category>cicd</category>
      <category>devops</category>
      <category>development</category>
    </item>
    <item>
      <title>Scanning the Damn Vulnerable Web App with StackHawk</title>
      <dc:creator>Scott Gerlach</dc:creator>
      <pubDate>Sat, 18 Apr 2020 17:02:48 +0000</pubDate>
      <link>https://dev.to/sgerlach/scanning-the-damn-vulnerable-web-app-with-stackhawk-2jmj</link>
      <guid>https://dev.to/sgerlach/scanning-the-damn-vulnerable-web-app-with-stackhawk-2jmj</guid>
      <description>&lt;p&gt;When we first introduced StackHawk to some of our close friends in the security industry and asked them to try it out, they tested it the same way we did. They ran HawkScan through its paces with one of the many vulnerable web applications security professionals set up online to help the community learn. They did this to have a semi-known outcome to see how StackHawk works. Enter Damn Vulnerable Web App. &lt;/p&gt;

&lt;p&gt;The &lt;a href="http://www.dvwa.co.uk/"&gt;Damn Vulnerable Web App&lt;/a&gt; (DVWA) is a tool made by &lt;a href="https://dewhurstsecurity.com/"&gt;Dewhurst Security&lt;/a&gt; to help security professionals and developers alike find and exploit &lt;a href="https://owasp.org/www-project-top-ten/"&gt;Web Application Vulnerabilities&lt;/a&gt;. It’s a great tool and worth checking out if you haven’t already.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--m2RrK6L---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jeq5ia9td7ibrr39hju1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--m2RrK6L---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/jeq5ia9td7ibrr39hju1.png" alt="alt text" title="DVWA Scan Results"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Results of StackHawk’s Dynamic Application Security Test (DAST) scan of the Damn Vulnerable Web App.&lt;/p&gt;

&lt;p&gt;Below are the details on how you can test StackHawk with the DVWA yourself. Note that this whole process can be done in ~10 minutes and provides a great example of how StackHawk works.&lt;/p&gt;

&lt;h2&gt;
  
  
  Initial Set Up
&lt;/h2&gt;

&lt;p&gt;StackHawk is built to find security bugs in a running application. To get DVWA up and running, I went the easy route and deployed the web app via a &lt;a href="https://www.docker.com/resources/what-container"&gt;Docker container&lt;/a&gt;. This gave me the freedom to use the app and not worry about fiddling with a LAMP stack. The default docker instructions &lt;code&gt;docker run --rm -it -p 80:80 vulnerables/web-dvwa&lt;/code&gt; exposes DVWA to the host machine interfaces on port 80, including &lt;code&gt;http://localhost/&lt;/code&gt;. From there, I could easily log in to the web interface and ensure everything was working as expected.&lt;/p&gt;

&lt;p&gt;If you’re following along at home, you’ll have to follow three simple steps to fully get DVWA up and running:&lt;br&gt;
Open &lt;a href="http://localhost"&gt;http://localhost&lt;/a&gt; and log in to the admin console using &lt;code&gt;username: admin&lt;/code&gt; and &lt;code&gt;password: admin&lt;/code&gt;&lt;br&gt;
Scroll to the bottom of the page to initialize the application database by clicking &lt;code&gt;Create / Reset Database&lt;/code&gt;&lt;br&gt;
Confirm you can log in again with &lt;code&gt;username: admin&lt;/code&gt; and &lt;code&gt;password: password&lt;/code&gt; and make sure you see the left side menu this time.&lt;/p&gt;
&lt;h2&gt;
  
  
  Starting a StackHawk Scan
&lt;/h2&gt;

&lt;p&gt;To start, if you don’t have an API key, please make your way over to &lt;a href="https://stackhawk.com"&gt;https://stackhawk.com&lt;/a&gt; and signup to get access. Once you have an API key and have defined an application and received the applicationId for your test you are ready to configure the scanner.&lt;/p&gt;

&lt;p&gt;StackHawk has a simplified configuration file written in &lt;a href="https://yaml.org/"&gt;YAML&lt;/a&gt; to make implementation easier and scalable. Automating scanning across the wide variety of applications out there introduces significant complexity, but we’ve simplified the configuration so you can get up and running quickly.&lt;/p&gt;

&lt;p&gt;Since we know the application lives on &lt;code&gt;http://localhost/&lt;/code&gt;, the beginning of our config file (stackhawk.yml) should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;applicationId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;your applicationID uuid&lt;/span&gt;&lt;span class="pi"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Development&lt;/span&gt;
&lt;span class="c1"&gt;# The url of the application to scan&lt;/span&gt;
  &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;span class="na"&gt;hawk&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#  # The web crawler / spider configuration&lt;/span&gt;
  &lt;span class="na"&gt;spider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#    # Enable the base spider for discovering your app's routes&lt;/span&gt;
    &lt;span class="na"&gt;base&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;# (default)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Within this section of our config file, we tell the scanner what the StackHawk applicationId is, what environment DVWA is running in, where the application can be found and what web crawling to do. In this instance, DVWA is a PHP application, so the base spider will work nicely to find and parse links and forms in the page (we support single page apps too – check &lt;a href="https://docs.stackhawk.com/hawkscan/configuration/openapi-configuration.html"&gt;out the docs&lt;/a&gt;). If we save this file to a directory on our local computer, say &lt;code&gt;~/dvwatest/&lt;/code&gt;, we can then begin a scanning run. To start StackHawk with our stackhawk.yml file defined, we simply run the command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;cd&lt;/span&gt; ~/dvwatest/
docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/hawk:rw &lt;span class="nt"&gt;-it&lt;/span&gt; stackhawk/hawkscan:latest stackhawk.yml
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Since all of the functionality of the web app is behind Form/Session authentication, running HawkScan at this point only discovers the login.php page. While that part is nifty, there’s no real meat there.&lt;/p&gt;

&lt;p&gt;DVWA comes with a default admin user that we set the password for in the beginning part of the article. Reviewing the login form, there is Login, the name of the Submit button with the value Login. It’s important for StackHawk to know that, because that’s how it will try to log in. There are also three different fields submitted:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Username&lt;/li&gt;
&lt;li&gt;Password&lt;/li&gt;
&lt;li&gt;user_token&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The first two fields are fairly self explanatory. The third field, user_token, is the &lt;a href="https://owasp.org/www-community/attacks/csrf"&gt;CSRF&lt;/a&gt; field that helps prevent &lt;a href="https://owasp.org/www-community/attacks/Credential_stuffing"&gt;form stuffing&lt;/a&gt;, or automated attempts to bypass the login page. The value for user_token is generated by the server and displayed in the page. The server expects that value back when the user attempts a login to validate the form was read and submitted in a regular fashion. It’s important for StackHawk to know the user_token as well so it can scrape the login page, find the value, pass it back to the server and complete the CSRF challenge. With all these additions, our config file is starting to look a bit more robust.&lt;/p&gt;

&lt;p&gt;We also need to set up some of the authentication parameters for the scanner to be able to log into the DVWA. We know it uses Form based authentication.&lt;/p&gt;

&lt;p&gt;When we made HawkScan, one the the things we wanted to improve was the Authentication process. The base scanner is sort of agnostic to whether or not your authentication worked and getting feedback to tell if authentication actually worked is at best, difficult. We’ve made that process better in the authentication section. We ask for a URL and a response code that should be accessible after authentication. When those succeed, the scanner continues. If they don’t the scanner stops and give you feedback about what didn’t go correctly in authentication.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;applicationId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;your applicationID uuid&lt;/span&gt;&lt;span class="pi"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Development&lt;/span&gt;
  &lt;span class="c1"&gt;# The url of your application to scan&lt;/span&gt;
  &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
  &lt;span class="c1"&gt;# Our scanner's capability is still in Alpha; If we notice a bug we'll use this email to reach out or provide a fix.&lt;/span&gt;
  &lt;span class="c1"&gt;# We will never use this contact for marketing purposes.&lt;/span&gt;
  &lt;span class="na"&gt;contactEmail&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;steve.s.hawk@example.com&lt;/span&gt; &lt;span class="c1"&gt;# (optional)&lt;/span&gt;
  &lt;span class="c1"&gt;# The risk level of the app&lt;/span&gt;
  &lt;span class="na"&gt;riskLevel&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;MEDIUM&lt;/span&gt; &lt;span class="c1"&gt;# The DVWA poses a Medium risk to my fictional company&lt;/span&gt;
  &lt;span class="c1"&gt;# The type of data sensitivity the web app maintains&lt;/span&gt;
  &lt;span class="na"&gt;appDataType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PII&lt;/span&gt; &lt;span class="c1"&gt;# It holds PII data and that’s pretty much it&lt;/span&gt;
 &lt;span class="c1"&gt;#  # The name of your anti csrf parameter&lt;/span&gt;
  &lt;span class="na"&gt;antiCsrfParam&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;user_token&lt;/span&gt; &lt;span class="c1"&gt;# here we define the CSRF field name so the scanner can pick it up&lt;/span&gt;

&lt;span class="c1"&gt;#  # Form POST based authentication configuration for scanning as a user.&lt;/span&gt;
&lt;span class="c1"&gt;#  # Enabling will force the scanner to scan as an&lt;/span&gt;
&lt;span class="c1"&gt;#  # authenticated user of your app.&lt;/span&gt;
&lt;span class="c1"&gt;#  # Authenticated requests will pass cookies received from the form POST&lt;/span&gt;
&lt;span class="c1"&gt;#  # to maintain authentication.&lt;/span&gt;
  &lt;span class="na"&gt;authentication&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#    # A regex to match against http responses to determine if the scan user is&lt;/span&gt;
&lt;span class="c1"&gt;#    # still logged in to your app&lt;/span&gt;
    &lt;span class="na"&gt;loggedInIndicator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;QLogout&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;E"&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;span class="c1"&gt;#    # A regex to match against http responses to determine if the scan user is&lt;/span&gt;
&lt;span class="c1"&gt;#    # logged out of your app&lt;/span&gt;
    &lt;span class="na"&gt;loggedOutIndicator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;QloginInput&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;E"&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;span class="c1"&gt;#   # A page that is only accessible being logged in. We will try to access this page&lt;/span&gt;
&lt;span class="c1"&gt;#   # to validate authentication worked&lt;/span&gt;
    &lt;span class="na"&gt;testPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;path&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/vulnerabilities/javascript/&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;HEADER&lt;/span&gt;
      &lt;span class="na"&gt;success&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;.*200.*"&lt;/span&gt;
    &lt;span class="na"&gt;usernamePassword&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;FORM&lt;/span&gt; &lt;span class="c1"&gt;# (optional)&lt;/span&gt;
&lt;span class="c1"&gt;#    # The route to a form POST to authenticate a user&lt;/span&gt;
      &lt;span class="na"&gt;loginPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/login.php&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;span class="c1"&gt;#    # The route to logout a user&lt;/span&gt;
      &lt;span class="na"&gt;logoutPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/logout.php&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;span class="c1"&gt;#    # The username field name in your authentication form&lt;/span&gt;
      &lt;span class="na"&gt;usernameField&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;username&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;span class="c1"&gt;#    # The password field name in your authentication form.&lt;/span&gt;
      &lt;span class="na"&gt;passwordField&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;span class="c1"&gt;#    # Other parameters that may be required by your log in form&lt;/span&gt;
      &lt;span class="na"&gt;otherParams&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# (optional)&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Login&lt;/span&gt;  &lt;span class="c1"&gt;# The login form parameter is needed to make login work&lt;/span&gt;
          &lt;span class="na"&gt;val&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Login"&lt;/span&gt;
        &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;security"&lt;/span&gt; &lt;span class="c1"&gt;# I'm not sure what this does in the app, but scans don't work without it&lt;/span&gt;
          &lt;span class="na"&gt;val&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;low"&lt;/span&gt;
&lt;span class="c1"&gt;#    # The username to authenticate as when scanning&lt;/span&gt;
      &lt;span class="na"&gt;scanUsername&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;admin&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
&lt;span class="c1"&gt;#    # The password of the scanUsername&lt;/span&gt;
      &lt;span class="na"&gt;scanPassword&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;

&lt;span class="na"&gt;hawk&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#  # Web crawler / spider configuration&lt;/span&gt;
  &lt;span class="na"&gt;spider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#    # Enable the base spider for discovering your app's routes&lt;/span&gt;
    &lt;span class="na"&gt;base&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;# (default)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;With this config file, StackHawk knows how to log in to the app. However, when I ran some scans, the results and discovered URLs are not quite what I was expecting. There were not enough URLs and WAY less vulnerabilities than I expected. When investigating the DVWA in my browser, I can see a few things that I must tell StackHawk for it to do a more thorough job.&lt;/p&gt;

&lt;p&gt;Browsing to the Logout Menu, the application instantly logs me out. What that means, is the scanner is logging me into the application to do the spidering of the app, browsing the links it can find and logging me out before it can test any of the pages. I need to tell the scanner about these things. My config now looks like this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;applicationId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;your applicationID uuid&lt;/span&gt;&lt;span class="pi"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Development&lt;/span&gt;
  &lt;span class="c1"&gt;# The url of your application to scan&lt;/span&gt;
  &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
  &lt;span class="c1"&gt;# Our scanner's capability is still in Alpha; If we notice a bug we'll use this email to reach out or provide a fix.&lt;/span&gt;
  &lt;span class="c1"&gt;# We will never use this contact for marketing purposes.&lt;/span&gt;
  &lt;span class="na"&gt;contactEmail&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;steve.s.hawk@example.com&lt;/span&gt; &lt;span class="c1"&gt;# (optional)&lt;/span&gt;
  &lt;span class="c1"&gt;# The risk level of the app&lt;/span&gt;
  &lt;span class="na"&gt;riskLevel&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;MEDIUM&lt;/span&gt; &lt;span class="c1"&gt;# The DVWA poses a Medium risk to my fictional company&lt;/span&gt;
  &lt;span class="c1"&gt;# The type of data sensitivity the web app maintains&lt;/span&gt;
  &lt;span class="na"&gt;appDataType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PII&lt;/span&gt; &lt;span class="c1"&gt;# It holds PII data and that’s pretty much it&lt;/span&gt;
  &lt;span class="na"&gt;sessionTokens&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# the session cookies DVWA uses in some fashion&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PHPSESSID"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dvwaSession"&lt;/span&gt;

&lt;span class="c1"&gt;#  # The name of your anti csrf parameter&lt;/span&gt;
  &lt;span class="na"&gt;antiCsrfParam&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;user_token&lt;/span&gt; &lt;span class="c1"&gt;# here we define the CSRF field name so the scanner can pick it up&lt;/span&gt;
  &lt;span class="c1"&gt;# What pages to not scan&lt;/span&gt;
  &lt;span class="na"&gt;excludePaths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="s"&gt;-"logout.php"&lt;/span&gt; &lt;span class="c1"&gt;# the scanner will log itself out if you don't ignore it&lt;/span&gt;

&lt;span class="c1"&gt;#  # Form POST based authentication configuration for scanning as a user.&lt;/span&gt;
&lt;span class="c1"&gt;#  # Enabling will force the scanner to scan as an&lt;/span&gt;
&lt;span class="c1"&gt;#  # authenticated user of your app.&lt;/span&gt;
&lt;span class="c1"&gt;#  # Authenticated requests will pass cookies received from the form POST&lt;/span&gt;
&lt;span class="c1"&gt;#  # to maintain authentication.&lt;/span&gt;
  &lt;span class="na"&gt;formAuth&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# This app uses Form Based auth&lt;/span&gt;
&lt;span class="c1"&gt;#    # The route to a form POST to authenticate a user&lt;/span&gt;
    &lt;span class="na"&gt;loginPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/login.php&lt;/span&gt; &lt;span class="c1"&gt;# this is the login page&lt;/span&gt;
&lt;span class="c1"&gt;#    # The route to logout a user&lt;/span&gt;
    &lt;span class="na"&gt;logoutPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/logout.php&lt;/span&gt; &lt;span class="c1"&gt;# tell the scanner where logout happens.&lt;/span&gt;
&lt;span class="c1"&gt;#    # The username field name in your authentication form&lt;/span&gt;
    &lt;span class="na"&gt;usernameField&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;username&lt;/span&gt; &lt;span class="c1"&gt;# here is the name of a field in the login form&lt;/span&gt;
&lt;span class="c1"&gt;#    # The password field name in your authentication form.&lt;/span&gt;
    &lt;span class="na"&gt;passwordField&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt; &lt;span class="c1"&gt;# here is the name of a field in the login form&lt;/span&gt;
&lt;span class="c1"&gt;#    # A regex to match against http responses to determine if the scan user is&lt;/span&gt;
&lt;span class="c1"&gt;#    # still logged in to your app&lt;/span&gt;
    &lt;span class="na"&gt;loggedInIndicator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;QLogout&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;E"&lt;/span&gt; &lt;span class="c1"&gt;# the \\Q and \\E are important indicators, but this field also take standard regex&lt;/span&gt;
&lt;span class="c1"&gt;#    # A regex to match against http responses to determine if the scan user is&lt;/span&gt;
&lt;span class="c1"&gt;#    # logged out of your app&lt;/span&gt;
    &lt;span class="na"&gt;loggedOutIndicator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;QloginInput&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;E"&lt;/span&gt; &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#    # Other parameters that may be required by your log in form&lt;/span&gt;

&lt;span class="c1"&gt;#    # Other parameters that may be required by your log in form&lt;/span&gt;
    &lt;span class="na"&gt;otherParams&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# (optional)&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Login&lt;/span&gt;  &lt;span class="c1"&gt;# The login form parameter is needed to make login work&lt;/span&gt;
        &lt;span class="na"&gt;val&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Login"&lt;/span&gt;
&lt;span class="c1"&gt;#    # The username to authenticate as when scanning&lt;/span&gt;
    &lt;span class="na"&gt;scanUsername&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;admin&lt;/span&gt; &lt;span class="c1"&gt;# DVWA default&lt;/span&gt;
&lt;span class="c1"&gt;#    # The password of the scanUsername&lt;/span&gt;
    &lt;span class="na"&gt;scanPassword&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt; &lt;span class="c1"&gt;# DVWA default&lt;/span&gt;
&lt;span class="na"&gt;hawk&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#  # Web crawler / spider configuration&lt;/span&gt;
  &lt;span class="na"&gt;spider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#    # Enable the base spider for discovering your app's routes&lt;/span&gt;
    &lt;span class="na"&gt;base&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;# (default)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we are starting to get better results, but something is still missing causing the scanner to not find all the links and test the pages. While we have described our application well, the scanner is still doing something incorrectly with the session when spidering links in the app. We can tell it to not browse or test some of the pages that are giving us trouble. For instance, the setup.php page has a button that rebuilds the entire database, that’s probably not helping our cause. Also, the security.php page has a button that turns on PHPIDS and make the app more secure and while that’s great, it makes our test not work well. The last one we are concerned about is the &lt;code&gt;/vulnerabilities/csrf/&lt;/code&gt; path that has the ability to change the users password. While that doesn’t affect the current scan, the scanner will change the password of the user and confuse you a lot!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="c1"&gt;# Complete configuration for DWVA StackHawk Scan&lt;/span&gt;
&lt;span class="na"&gt;app&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;applicationId&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;{&lt;/span&gt;&lt;span class="nv"&gt;your applicationID uuid&lt;/span&gt;&lt;span class="pi"&gt;}&lt;/span&gt;
  &lt;span class="na"&gt;env&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Development&lt;/span&gt;
  &lt;span class="c1"&gt;# The url of your application to scan&lt;/span&gt;
  &lt;span class="na"&gt;host&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://localhost&lt;/span&gt; &lt;span class="c1"&gt;# (required)&lt;/span&gt;
  &lt;span class="c1"&gt;# Our scanner's capability is still in Alpha; If we notice a bug we'll use this email to reach out or provide a fix.&lt;/span&gt;
  &lt;span class="c1"&gt;# We will never use this contact for marketing purposes.&lt;/span&gt;
  &lt;span class="na"&gt;contactEmail&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;steve.s.hawk@example.com&lt;/span&gt; &lt;span class="c1"&gt;# (optional)&lt;/span&gt;
  &lt;span class="c1"&gt;# The risk level of the app&lt;/span&gt;
  &lt;span class="na"&gt;riskLevel&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;MEDIUM&lt;/span&gt; &lt;span class="c1"&gt;# The DVWA poses a Medium risk to my fictional company&lt;/span&gt;
  &lt;span class="c1"&gt;# The type of data sensitivity the web app maintains&lt;/span&gt;
  &lt;span class="na"&gt;appDataType&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;PII&lt;/span&gt; &lt;span class="c1"&gt;# It holds PII data and that’s pretty much it&lt;/span&gt;
  &lt;span class="na"&gt;sessionTokens&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# the session cookies DVWA uses in some fashion&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;PHPSESSID"&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;dvwaSession"&lt;/span&gt;

&lt;span class="c1"&gt;#  # The name of your anti csrf parameter&lt;/span&gt;
  &lt;span class="na"&gt;antiCsrfParam&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;user_token&lt;/span&gt; &lt;span class="c1"&gt;# here we define the CSRF field name so the scanner can pick it up&lt;/span&gt;
  &lt;span class="na"&gt;excludePaths&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/setup.php"&lt;/span&gt; &lt;span class="c1"&gt;# The scanner resets the DB :)&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/security.php"&lt;/span&gt; &lt;span class="c1"&gt;#the scanner turns on PHPIDS here&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/vulnerabilities/csrf/*"&lt;/span&gt; &lt;span class="c1"&gt;#this page changes the admin password&lt;/span&gt;
    &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;/logout.php"&lt;/span&gt; &lt;span class="c1"&gt;# the scanner will log itself out if you don't ignore here&lt;/span&gt;

&lt;span class="c1"&gt;#  # Form POST based authentication configuration for scanning as a user.&lt;/span&gt;
&lt;span class="c1"&gt;#  # Enabling will force the scanner to scan as an&lt;/span&gt;
&lt;span class="c1"&gt;#  # authenticated user of your app.&lt;/span&gt;
&lt;span class="c1"&gt;#  # Authenticated requests will pass cookies received from the form POST&lt;/span&gt;
&lt;span class="c1"&gt;#  # to maintain authentication.&lt;/span&gt;
  &lt;span class="na"&gt;formAuth&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# This app uses Form Based auth&lt;/span&gt;
&lt;span class="c1"&gt;#    # The route to a form POST to authenticate a user&lt;/span&gt;
    &lt;span class="na"&gt;loginPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/login.php&lt;/span&gt; &lt;span class="c1"&gt;# this is the login page&lt;/span&gt;
&lt;span class="c1"&gt;#    # The route to logout a user&lt;/span&gt;
    &lt;span class="na"&gt;logoutPath&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;/logout.php&lt;/span&gt; &lt;span class="c1"&gt;# tell the scanner where logout happens.&lt;/span&gt;
&lt;span class="c1"&gt;#    # The username field name in your authentication form&lt;/span&gt;
    &lt;span class="na"&gt;usernameField&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;username&lt;/span&gt; &lt;span class="c1"&gt;# here is the name of a field in the login form&lt;/span&gt;
&lt;span class="c1"&gt;#    # The password field name in your authentication form.&lt;/span&gt;
    &lt;span class="na"&gt;passwordField&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt; &lt;span class="c1"&gt;# here is the name of a field in the login form&lt;/span&gt;
&lt;span class="c1"&gt;#    # A regex to match against http responses to determine if the scan user is&lt;/span&gt;
&lt;span class="c1"&gt;#    # still logged in to your app&lt;/span&gt;
    &lt;span class="na"&gt;loggedInIndicator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;QLogout&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;E"&lt;/span&gt; &lt;span class="c1"&gt;# the \\Q and \\E are important indicators, but this field also take standard regex&lt;/span&gt;
&lt;span class="c1"&gt;#    # A regex to match against http responses to determine if the scan user is&lt;/span&gt;
&lt;span class="c1"&gt;#    # logged out of your app&lt;/span&gt;
    &lt;span class="na"&gt;loggedOutIndicator&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;QloginInput&lt;/span&gt;&lt;span class="se"&gt;\\&lt;/span&gt;&lt;span class="s"&gt;E"&lt;/span&gt; &lt;span class="c1"&gt;#&lt;/span&gt;
&lt;span class="c1"&gt;#    # Other parameters that may be required by your log in form&lt;/span&gt;

&lt;span class="c1"&gt;#    # Other parameters that may be required by your log in form&lt;/span&gt;
    &lt;span class="na"&gt;otherParams&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="c1"&gt;# (optional)&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Login&lt;/span&gt;  &lt;span class="c1"&gt;# The login form parameter is needed to make login work&lt;/span&gt;
        &lt;span class="na"&gt;val&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Login"&lt;/span&gt;
&lt;span class="c1"&gt;#    # The username to authenticate as when scanning&lt;/span&gt;
    &lt;span class="na"&gt;scanUsername&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;admin&lt;/span&gt; &lt;span class="c1"&gt;# DVWA default&lt;/span&gt;
&lt;span class="c1"&gt;#    # The password of the scanUsername&lt;/span&gt;
    &lt;span class="na"&gt;scanPassword&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;password&lt;/span&gt; &lt;span class="c1"&gt;# DVWA default&lt;/span&gt;
&lt;span class="na"&gt;hawk&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#  # Web crawler / spider configuration&lt;/span&gt;
  &lt;span class="na"&gt;spider&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;span class="c1"&gt;#    # Enable the base spider for discovering your app's routes&lt;/span&gt;
    &lt;span class="na"&gt;base&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="no"&gt;true&lt;/span&gt; &lt;span class="c1"&gt;# (default)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Now we have a working config for DVWA and can effectively scan the app and get results from the scanner. All of the results of these scans should be viewable from the direct link printed at the end of the scan in the terminal. From there you should be able to browse each of the issue and find the request response pairs that made an alert trigger.&lt;/p&gt;

&lt;p&gt;While the iteration to make this work was not difficult, you do need to understand how the application behaves and what things could be causing the scanner to not be able to do its job. Now we have a working config for DVWA and can effectively scan the app and get results from the scanner. While the iteration to make this work was not difficult, you do need to understand how the application behaves and what things could be causing the scanner to not be able to do its job. To test StackHawk scanning the Damn Vulnerable Web App or your own application, sign up for an account at &lt;a href="https://www.stackhawk.com/"&gt;stackhawk.com&lt;/a&gt;&lt;/p&gt;

</description>
      <category>appsec</category>
      <category>development</category>
      <category>dast</category>
      <category>security</category>
    </item>
  </channel>
</rss>
