T09 · Insecure Skill Coding Practices
Warning
- Location
- references/e2e-testing.md:136
- Finding
- Unprotected Authentication State and Hardcoded Test Credential Pattern## Vulnerability Details **File Location**: `references/e2e-testing.md:48` and `references/e2e-testing.md:136-147` **Vulnerability Type**: Plaintext sensitive data and unsafe authentication artifact handling **Risk Level**: Medium ### Vulnerable Code ```typescript { name: 'chromium', use: { ...devices['Desktop Chrome'], storageState: 'e2e/.auth/user.json' }, dependencies: ['setup'], }, ``` ```typescript // e2e/fixtures/auth.fixture.ts import { test as setup } from '@playwright/test'; setup('authenticate', async ({ page }) => { await page.goto('/login'); await page.getByLabel('Email').fill('testuser@example.com'); await page.getByLabel('Password').fill('TestPassword123!'); await page.getByRole('button', { name: /sign in/i }).click(); await page.waitForURL('/dashboard'); await page.context().storageState({ path: 'e2e/.auth/user.json' }); }); ``` Tests receive auth state via `storageState` in config projects. ### Technical Analysis The guidance demonstrates embedding a password directly in test source and persisting Playwright authentication state under the repository directory. A Playwright storage-state file can contain reusable cookies, bearer tokens, local-storage entries, and other session material. The document does not require the `e2e/.auth/` directory to be excluded from version control, restrict file permissions, remove generated state after execution, or prevent the file from being published as a CI artifact. Although the shown password appears to be an example credential rather than a verified production secret, following this pattern with real test credentials or sessions can expose authentication material. ### Attack Path 1. A developer follows the documented fixture and substitutes credentials for a functioning test account. 2. Playwright authenticates and writes session cookies or tokens to `e2e/.auth/user.json`. 3. The generated file is accidentally committed, ...[truncated 829 chars]
- Remediation
- ## Remediation Suggestions - Require `e2e/.auth/` and all generated storage-state files to be listed in `.gitignore`. - Obtain test credentials from an approved environment-variable or CI secret store rather than embedding them in source. - Use a dedicated, isolated, least-privilege test account with short-lived credentials. - Create authentication-state files with restrictive owner-only permissions where supported. - Delete storage-state files in test teardown and prevent them from being included in logs, caches, screenshots, traces, and uploaded artifacts. - Prefer short-lived sessions and revoke test sessions after the test run. - Add secret scanning and repository checks that reject committed storage-state files or hardcoded credentials.
