kiese
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights New
    • Engagement control
    • Make a copy
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Make a copy Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # Secure System Development Lab 4 - DAST **Team Members:** * Daniyar Cherekbashev (d.cherekbashev@innopolis.university) * Gleb Statkevich (g.statkevich@innopolis.university) * Daria Kalashnikova (d.kalashnikova@innopolis.university) ## Task 1 - Theory 1. Explain: * What is DAST? **A:** DAST (Dynamic Application Security Testing) is a testing process with purpose to find weaknesses and vulnerabilities in the software in a runtime. It is test the security of web applications by simulating attacks from the point of view of a malicious hacker. * How does dynamic security testing work? **A:** Dynamic security testing = sending malicious requests to application + monitoring responses. This process can help identify vulnerabilities, that could be exploited by attackers. By identifying these vulnerabilities, developers can take steps to protect their applications from potential attacks. * Explain how a context can be useful in DAST. **A:** Context can be used by a scanner to access deep features of an application. Essentially, a scanner does not have comprehensive information about available APIs and their endpoints. It also doesn't have auth data for certain functions etc. For example, if there is a web application, the context may contain info about hidden pages (admin dashboard for example) and authentication information. The scanner will be able to interact with the app not only as a foreign user, but also as a user with valid access. * How is an authenticated scan different from an unauthenticated scan? **A:** Unauthenticated scan allows to assess the security of software from the point of view of a foreign user. This user have no special rights/accesses. In other words, if we have a website, the scanner will act like visitor. On the other hand, an authenticated scan acts like a legitimate user with certain permissions. The scanner may detect if the user has obtained more privileges than they should have. Additionally, an authenticated scanner will analyze APIs that are available only for authenticated users (for example, we may have some service API for dev parties that are accessible only with token) * What are the advantages of the DAST methodology? **A:** - allows to assess the entire software without access to the source code. This is useful in cases where external software that do not have access to the sources is used. - it also allows to find logical errors in the code that would be difficult to detect using static scanning methods (for example, sensitive data in the DB that is leaked during runtime). - the most significant advantage is its precision. If the scanner is able to detect an exploit, than it is likely that there is real vulnerability that could be exploited. This makes easier to prioritize and fix found vulnerabilities. * Are there any downsides to the DAST methodology? **A:** - it is expensive tool that requires a running environment with highly realistic data and minimum number of assumptions. - it also can face different types of protection, which can prevent DAST from finding vulnerabilities. This is because the protection may filter out the payload due to some factors. If an attacker is able to bypass protection, the vulnerability can be exploited later. - it is difficult to quickly locate the root cause of the weakness, as we only have access to the payload and output. 2. List and explain the main criteria when choosing a DAST tool. **A:** - **Easy-to-Use.** Consider user-friendly interface and how easy it is to configure and run scans. A user-friendly tool can save time during the testing process. - **Report format.** If it’s not comprehensive and understandable, it will be useless - **Coverage.** range of vulnerabilities the tool can detect for common vulnerabilities, accuracy and quality of scanning, their maintainenace. The scanner should be aware of recent techniques used by attackers to be able to detect weaknesses. - **Cost.** Consider the total cost of using the DAST tool, including any licensing fees, maintenance costs, and any additional features/services. Ensure that tool fits your budget constraints. 3. According to the “Shift Everywhere” paradigm, Security tools in CI/CD should be used where they can bring maximum benefit. Based on this, give and explain at what stage(s) of the development process dynamic analysis can be introduced. **A:** DAST should be used after auto-tests and static analysis tools. Since DAST is expensive, it takes a lot time to run and process project, so there is no need to run DAST if the weaknesses can be found statically. Running DAST might find the same weaknesses, but it would just waste time and computational resources on something that has already been identified. 4. What is Fuzzing? What is/are the key(s) difference between Fuzzing and common DAST? **A:** Fuzzing is technique used to find weaknesses in the runtime of software by generating a large number of different inputs. They are designed (by special tools) to cause the software to crash, DoS, or other failures cases. Fuzzing can help to identify issues with memory management/leaks, incorrect calculations, identify problems with multithreading and other synchronization issues. 5. List and describe the different type of Fuzzers you know. **A:** - Application fuzzing - is a technique that involves testing an application's API (for example REST) with high frequency and large inputs of different types - Protocol fuzzig identify vulnerabilities in the processing of a protocol. The main purpose is to prevent protocol requests from being misinterpreted as commands and executed on the server. - File format fuzzing - send corrupted files (with incorrect attributes), files that contain dangerous parts, and more ## Task 2 - Deploy the vulnerable web app For this lab, we'll be using Juice Shop + StackHawk Create helm chart with `helm create juice-shop` Then, modify `values.yaml` to use juice-shop container and port 3000 ```yaml image: repository: bkimminich/juice-shop pullPolicy: IfNotPresent # Overrides the image tag whose default is the chart appVersion. tag: "latest" ``` ```yaml service: type: ClusterIP port: 3000 ``` Install the chart with `helm install juice-shop --namespace juice-shop --create-namespace .` ![image](https://hackmd.io/_uploads/SkGgIsfbR.png) Verify installation: ![image](https://hackmd.io/_uploads/SksTHsMWA.png) We also need to configure port forwarding with `kubectl --namespace juice-shop port-forward svc/juice-shop 8047:3000`: ![image](https://hackmd.io/_uploads/Sk8cDof-C.png) Now, we can add deployment job as the part of Gitlab CI. Repo for deployment ![image](https://hackmd.io/_uploads/rJ3BsnMWA.png) We need to save the kube config file as base64 string in the environment variables in Gitlab ![image](https://hackmd.io/_uploads/S1LrCiGb0.png) ![image](https://hackmd.io/_uploads/r1PY0ofZC.png) Deploy job: ```yaml stages: - deploy variables: CHART_NAME: juice-shop deploy_job: stage: deploy image: name: alpine/helm:latest entrypoint: [""] script: - mkdir -p ~/.kube/ - echo $KUBE_CONFIG | base64 -d > ~/.kube/config - chmod 600 ~/.kube/config - helm upgrade ${CHART_NAME} --install --values=./values.yaml --create-namespace --namespace ${CHART_NAME} . ``` ## Task 3 - Dynamic Analysis 1. StackHawk is not able to resolve docker: alias so we have to determine and put internal docker address in host <span style="color: green;">stackhawk.yml</span> ```yaml app: applicationId: 480a55d0-3cc1-4835-b508-3cb6964666e1 env: Development host: http://172.18.0.4:3000 openApiConf: filePath: swagger.yml autoPolicy: true autoInputVectors: true ``` Add HAWK_API_ID and HAWK_API_SECRET env variables: ![image](https://hackmd.io/_uploads/H1IkARzZA.png) Add job in <span style="color: green;">.gitlab-ci.yml</span> ```yaml dast_job: stage: scan-dast tags: - docker script: - docker run -d -e API_KEY="hawk.${HAWK_API_ID}.${HAWK_API_SECRET}" -e NO_COLOR=true --name stackhawk --entrypoint "/bin/sleep" --user root --rm stackhawk/hawkscan infinity - docker exec stackhawk "/bin/mkdir" -p /hawk - docker cp ./swagger.yml stackhawk:/hawk/ - docker cp ./stackhawk.yml stackhawk:/hawk/ - docker exec -t stackhawk "/zap/hawk" scan ``` Unathenticated scan result: ![image](https://hackmd.io/_uploads/SkUO_J7WR.png) ![image](https://hackmd.io/_uploads/BkUwOk7bC.png) 2. Added form-based authentication method, for email and password I took some pre-built juice-shop credentials from https://github.com/juice-shop/juice-shop/blob/master/data/static/users.yml to not take one more step for registration ```yaml antiCsrfParam: csrfToken authentication: cookieAuthorization: cookieNames: - JSESSIONID loggedInIndicator: "HTTP.*2[0-9][0-9]\\s*O[kK](\\s*)|HTTP.*3[0-9][0-9].*" loggedOutIndicator: "HTTP.*4[0-9][0-9](\\s*)Unauthorized.*" usernamePassword: type: FORM loginPagePath: /#/login loginPath: /#/login usernameField: email passwordField: password scanUsername: ${AUTH_EMAIL} scanPassword: ${AUTH_PASSWORD} otherParams: - name: rememberMe-input val: "true" testPath: path: /profile success: ".*2[0-9]{2}.*" requestMethod: GET ``` Authenticated scan result: ![image](https://hackmd.io/_uploads/r13EGgmWR.png) ![image](https://hackmd.io/_uploads/rJUSzgmWR.png) ![image](https://hackmd.io/_uploads/S1UDMgXZR.png) Compared to unauthenticated scan, it found 18 more paths available paths 4. In a custom context, I excluded some paths to see how it will be reflected in the scan results. For that, I added to `stackhawk.yml` ```yaml excludePaths: - "/assets" - "/b2b" ``` Assets should be definitely unnecessary in the scan, while b2b path may contain some order information. Job result: ![image](https://hackmd.io/_uploads/HkFoKl7bA.png) ![image](https://hackmd.io/_uploads/BJ8pFlmbA.png) Scan took a little bit less time compared to the full authenticated one and found 3 less path routes, however, findings remained the same. 6. OpenAPI specification for juice-shop is located at [swagger.yml](https://github.com/juice-shop/juice-shop/blob/master/swagger.yml) of the juice-shop project and was used by default while StackHawk app creation.

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully