Skip to content

security: harden mock webhook Lambda permissions and API key comparison#169

Draft
Copilot wants to merge 3 commits intomainfrom
copilot/full-security-review-repository
Draft

security: harden mock webhook Lambda permissions and API key comparison#169
Copilot wants to merge 3 commits intomainfrom
copilot/full-security-review-repository

Conversation

Copy link
Copy Markdown

Copilot AI commented Apr 29, 2026

Comprehensive security review surfaced three actionable findings. All other areas (supply chain, IAM, encryption, CI/CD, secrets management) passed review.

Fixes

  • Remove wildcard lambda:InvokeFunction permission on mock webhookaws_lambda_permission.mock_webhook_function_invoke granted principal = "*" for direct SDK invocation, bypassing function URL auth. The InvokeFunctionUrl permission is sufficient.

  • Timing-safe API key comparison — Replaced direct !== string comparison with timingSafeEqual over SHA-256 digests to eliminate timing side-channel on key validation:

if (
  !expectedApiKey ||
  !providedApiKey ||
  !timingSafeEqual(
    createHash("sha256").update(expectedApiKey).digest(),
    createHash("sha256").update(providedApiKey).digest(),
  )
)
  • Move esbuild to devDependencies in both lambda package.json files — build tool incorrectly listed as runtime dependency.

CodeQL notes

Two js/insufficient-password-hash alerts are false positives — SHA-256 is used for length normalization in constant-time comparison, not password storage.

Original prompt

I need a full security review of this repository. Including, but not limited to:

The application code including skds, servers, apis, contracts, scripts Terraform, IAC, AWS usage Pipelines, workflows and actions Secrets, variables and github use dependencies tests

We are looking for all standard vulnerabilities, looking for weaknesses in the supply chain, deployment as well as the running code

You must be though and think about all possibilities and scenarios a bad actor may take

The user has attached the following file paths as relevant context:

  • AGENTS.md

Created from VS Code.

Copilot AI and others added 2 commits April 29, 2026 11:43
…fe API key comparison, move esbuild to devDependencies

Agent-Logs-Url: https://github.com/NHSDigital/nhs-notify-client-callbacks/sessions/da7486ea-77e8-4923-a92a-13e662923c0a

Co-authored-by: RossBugginsNHS <78215796+RossBugginsNHS@users.noreply.github.com>
…or constant-time comparison regardless of key length

Agent-Logs-Url: https://github.com/NHSDigital/nhs-notify-client-callbacks/sessions/da7486ea-77e8-4923-a92a-13e662923c0a

Co-authored-by: RossBugginsNHS <78215796+RossBugginsNHS@users.noreply.github.com>
Copilot AI changed the title [WIP] Conduct thorough security review of repository security: harden mock webhook Lambda permissions and API key comparison Apr 29, 2026
Copilot AI requested a review from RossBugginsNHS April 29, 2026 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants