LESSON 32 · INTERMEDIATE5 min read

Project: Secrets and Access Review

Audit an application for exposed secrets, weak authorisation boundaries, and excessive privilege, then deliver a prioritised remediation plan.

OWASP Top 10 · MITRE ATT&CK · NIST CSF 2.0Free to readModule 7 of 14
YOUR NEXT SMALL WINS

By the end, you’ll be able to…

  • Explain the difference between authentication and authorisation.
  • Apply role-based and attribute-based access control to a real permission model.
  • Detect secrets in source code, configuration, logs, and Git history.
  • Produce a remediation plan for secret rotation and least privilege.

01Authentication Is Not Authorisation

Authentication answers 'who are you?'. Authorisation answers 'what are you allowed to do?'. A system can authenticate every user correctly and still be critically insecure if it does not check permissions on every request. Many breaches begin with a valid account that can reach data belonging to another user, tenant, or department.

Access control should be enforced on the server, close to the data. Hiding a button in the browser is user-interface convenience, not security. Every API endpoint, background job, export, and administrative action must check the caller's identity and authority. Never trust a role, user ID, tenant ID, or price supplied by the client without verifying it against the authenticated session.

Common models include role-based access control (RBAC), where roles map to permissions; attribute-based access control (ABAC), where rules consider attributes such as department, resource owner, and time; and relationship-based access control, where the user's relationship to the resource decides access. Choose the simplest model that expresses the policy, and make the policy testable.

02Least Privilege in Practice

Least privilege applies to people, services, and machines. A support agent should not be able to read every customer record just because the support tool technically allows it. A reporting service should not hold database administrator credentials. A CI job should deploy one application, not own the entire cloud account. A developer's laptop should not contain production secrets.

Start with an access inventory: who or what needs which resource, for what action, under which conditions, and for how long. Then remove unused permissions, separate duties, and require approval for high-risk actions. Use time-bound elevation for administrative work. Review access regularly, especially after role changes and departures. Log and monitor privileged actions because they are high-value targets.

Authorisation failures often hide in the 'unhappy path'. Test what happens when a user changes an ID, omits a tenant header, requests an admin route, replays a request, or accesses a draft or deleted record. Tests should prove that unauthorised actions fail, not only that authorised actions succeed.

authorisation_check.py🐍Python
Ctrl + ↵
Output
Click Run or press Ctrl+Enter
Output will appear here after you run the code.

03Find Secrets Before Attackers Do

Secrets include API keys, database passwords, private keys, session-signing keys, webhook secrets, and cloud credentials. They end up in source code, configuration files, environment dumps, logs, crash reports, screenshots, CI variables, and Git history. A secret committed once can remain recoverable even after the file is deleted.

Use a combination of prevention and detection. Add a secret scanner to pre-commit hooks and CI. Keep a .gitignore that excludes local environment files. Use a secret manager or platform-provided identity for workloads. Scan the full Git history, not just the current tree. If a secret is found, assume it is compromised: revoke or rotate it first, then remove it from history and fix the process that exposed it.

Not every long string is a secret. Validate findings to avoid an alert flood. A public client identifier, a test fixture, or a documented placeholder may be safe. A private key, a live cloud access key, a production database URL with a password, or a session-signing secret is not. Record the location, type, exposure window, and rotation status.

secret-triage.shShell
# Search the current tree for common high-risk patterns.git grep -nE "(AKIA[0-9A-Z]{16}|-----BEGIN (RSA |EC |OPENSSH )?PRIVATE KEY-----|ghp_[A-Za-z0-9]{20,})" || true# Search the full history, not only the working tree.git log -p --all -S "AKIA" -- . | head -100# Check whether local environment files are ignored.git check-ignore -v .env .env.local 2>/dev/null || true# List tracked files that look like secret stores.git ls-files | grep -Ei "(\.env|\.pem|\.key|credentials|secret)" || true
Outputstdout
src/config.js:12: const key = "AKIAIOSFODNN7EXAMPLE"
.env is ignored by .gitignore:3
config/production.env

04Project Brief: Secrets and Access Review

Choose a small application you own, or use a synthetic sample repository. Do not scan systems you do not control. Review three areas: secret exposure, authentication and session handling, and authorisation boundaries. Produce a findings table with severity, evidence, impact, and remediation.

For secrets, include the type, location, whether it is live or a placeholder, whether it appears in Git history, and the rotation status. For access, include an access matrix showing roles and actions, plus at least three negative tests that prove unauthorised requests fail. For authentication, review password storage, MFA coverage, session lifetime, logout, and reset flow.

Finish with a 30/60/90-day plan. Immediate actions should revoke exposed secrets and close critical authorisation gaps. Near-term work should add tests, scanning, and least-privilege changes. Longer-term work should improve access reviews, monitoring, and developer education. Redact all real secrets and personal data from the published report.

access-review-template.mdPlain text
# Secrets and Access Review## ScopeRepository, staging environment, and two synthetic user roles.## Findings### F-01: Live payment API key in Git history- Severity: critical- Evidence: commit abc123, file config/production.js, line 12 (redacted)- Exposure: repository visible to 14 collaborators since 2026-03-01- Action: revoke key now, issue replacement, purge history, add secret scanning- Verification: old key returns 401; scanner blocks new commits### F-02: Invoice endpoint lacks tenant check- Severity: high- Evidence: GET /api/invoices/1042 returns another tenant's invoice for role=user- Action: scope query by authenticated tenant, add negative test- Verification: user B receives 404 for user A's invoice## Access matrix| Role | View own invoice | View all invoices | Issue refund || --- | --- | --- | --- || customer | yes | no | no || support | yes | no | approval required || admin | yes | yes | yes, audited |## 30/60/9030 days: rotate secrets, fix tenant check, add CI scanning.60 days: add authorisation tests and access review.90 days: time-bound admin elevation and quarterly review.
LET IT CLICK

The ideas worth keeping.

  • Authentication and authorisation are separate; enforce authorisation server-side on every request.
  • Least privilege applies to people, services, CI jobs, and machines.
  • A committed secret is compromised even if the file is later deleted; revoke first.
  • Negative tests are essential: prove that unauthorised access actually fails.
TURN UNDERSTANDING INTO SOMETHING YOU CAN DO

Make it yours.

Type and test your code right here in the interactive workspace. Run your solution, check the output, and compare with the worked guide when ready.

01

Exercise 1: Build an access matrix

A support tool has three roles: customer, support, and admin. Customers can view their own tickets. Support can view and update any ticket but cannot delete. Admins can do everything, including delete and export. Write the matrix and identify one action that should require additional approval.

Explore a worked solution
one_possible_solution.mdCybersecurity
Rows: customer, support, admin. Columns: view own, view any, update, delete, export. Customer: yes, no, own only, no, no. Support: yes, yes, yes, no, no. Admin: yes, yes, yes, yes, yes. Additional approval: bulk export of all tickets, because it creates a large data-exfiltration path. Require a reason, time-bound approval, and audit logging.

The matrix makes implicit assumptions explicit. High-impact actions such as bulk export need more than a static role check.

02

Exercise 2: Respond to a leaked key

A developer accidentally commits a cloud access key to a public repository. List the first five actions in order and explain why rotation comes before history cleanup.

Explore a worked solution
one_possible_solution.mdCybersecurity
1. Revoke or disable the key immediately. 2. Review cloud audit logs for use of the key and identify any resources created, accessed, or changed. 3. Issue a replacement key with least privilege and store it in a secret manager. 4. Remove the secret from the repository history and rotate any related credentials. 5. Add secret scanning to pre-commit and CI, and document the incident. Rotation comes first because history cleanup is slow and copies of the repository may already exist; until the key is revoked, the attacker can keep using it.

Assume a public secret is compromised. Containment precedes cleanup, and evidence review determines whether the key was used.

A SMALL QUESTION. A USEFUL NEXT STEP.

What stayed with you?

Check the ideas while they’re fresh. Your answers stay in this page and feedback appears as you go.

A LITTLE ACTIVE RECALL0 / 4 answered
01What is the difference between authentication and authorisation?
02Which check best prevents an IDOR vulnerability?
03What should you do first when a live secret is found in a repository?
04Why is least privilege important for service accounts?

Keep exploring.

The official references behind this lesson, when you want a second angle or the full details.

MODULE 07 · PRACTICAL SELF-CHECK

Pause. Put the pieces together.

You’ve reached the end of Cryptography, Identity, and Access. Before moving on, use this task to check what you can do independently.

Complete a secrets and access review with findings, fixes, and verification evidence, including a certificate chain and expiry check.

Try it in your own environment and write down the result. This is a self-check; reading completion does not evaluate your code.

Review this module

One lesson closer.

Reading is a start. Trying it yourself makes the connection.

Completion is saved in this browser. It records reading and hands-on practice progress.