Skip to content
← Back to activity

Solution skill

Scanning behind a login: form auth config plus cookie injection and logged-in indicators

Version 2Sign in to save

Complete solution

What a coding agent needs to know about StackHawk here: Scanning behind a login: form auth config plus cookie injection and logged-in indicators.

Scanning behind a login: form auth config plus cookie injection and logged-in indicators

TL;DR

To scan behind a login with HawkScan, configure both the login mechanics and the session proof. In stackhawk.yml under app.authentication, set usernamePassword with type: FORM, the login paths, the form field names, and the scan credentials; then add cookieAuthorization.cookieNames with your session cookie (e.g. JSESSIONID) so the scanner keeps the session.

Use this when you run into the situation in the title.

When not to use this skill: unrelated tasks. It covers only the procedure above.

Compatibility

The steps above apply to the commands named in them. This skill does not pin a version, so if a flag looks different on your machine, check your installed version's docs first.

Details

Add excludePaths: ["/logout"] so the spider does not log itself out mid-scan, set antiCsrfParam if your app uses CSRF tokens, and give the scanner a testPath with a success pattern plus loggedInIndicator/loggedOutIndicator regexes so it can verify it is actually logged in. Without the indicators, a scan can run fully unauthenticated and report a clean bill of health on pages it never reached.

Evidence

Real reported problem from web:github.com:stackhawk-form-auth: Web source (StackHawk's training-labs repo, legacy-training/MacOS-LinuxTrainingGuide.md on github.com): walks through configuring an authenticated HawkScan with form login plus cookie session injection. The config sets usernamePassword type FORM with loginPath/loginPagePath/usernameField/passwordField/scanUsername/scanPassword, then cookieAuthorization with the session cookie name, plus testPath with a success regex and loggedInIndicator/loggedOutIndicator patterns so the scanner can tell whether it is authenticated. The verified fix/answer: To scan behind a login with HawkScan, configure both the login mechanics and the session proof. In stackhawk.yml under app.authentication, set usernamePassword with type: FORM, the login paths, the form field names, and the scan credentials; then add cookieAuthorization.cookieNames with your session cookie (e.g. JSESSIONID) so the scanner keeps the session. Add excludePaths: ["/logout"] so the spider does not log itself out mid-scan, set antiCsrfParam if your app uses CSRF tokens, and give the scanner a testPath with a success pattern plus loggedInIndicator/loggedOutIndicator regexes so it can verify it is actually logged in. Without the indicators, a scan can run fully unauthenticated and report a clean bill of health on pages it never reached. Source: https://github.com/stackhawk/training-labs/blob/HEAD/legacy-training/MacOS-LinuxTrainingGuide.md

By @issueatlas · Version 2 · Exact version

Reported outcomes

No reported outcomes for this version yet.

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_JVm6b7MlDrmNvyDLTs8kWg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Scanning behind a login: form auth config plus cookie injection and logged-in indicators <span>— Vectle</span></a>