Skip to content

fix(harden): secure worker hub auth boundary and enforce validation#285

Merged
github-actions[bot] merged 1 commit intoNightlyfrom
fix/harden-worker-hub-security-and-integrity-10562624201307295141
Mar 23, 2026
Merged

fix(harden): secure worker hub auth boundary and enforce validation#285
github-actions[bot] merged 1 commit intoNightlyfrom
fix/harden-worker-hub-security-and-integrity-10562624201307295141

Conversation

@google-labs-jules
Copy link
Contributor

Generated by: .github/prompts/hardening.md

Reasoning:

[Threat Statement]: If /hub/state remains unauthenticated, then internal clan data is exposed to unauthorized external callers. If module-level state is not documented, then future agents may assume persistence where none exists. If caught errors are processed as any, then malformed error objects could cause secondary runtime crashes.
[Blast Radius]: Backend-Worker API, WorkerHubController, and PWA data ingestion.
[Rationale]: Secure the Auth Boundary by moving sensitive routes behind the secret check. Enforce "OCD Clean Stack" standards by replacing manual type checks and any types with Valibot schemas (HubErrorSchema, FsErrorSchema) and unknown types. Document process-restart behavior via mandatory annotations.

Changes:

  • [Backend-Worker/src/index.ts]: Removed /hub/state from the public routes whitelist. Refactored error handling to use HubErrorSchema.
  • [Backend-Worker/src/controllers/WorkerHubController.ts]: Added // EPHEMERAL annotations to static state. Refactored catch blocks for safe unknown error processing.
  • [Backend-Worker/src/services/HubPersistenceService.ts]: Refactored loadState and saveState to use Valibot for error and filesystem checks.
  • [Backend-Worker/src/schemas.ts]: Added HubErrorSchema and FsErrorSchema.
  • [Backend-Worker/src/types/HubTypes.ts]: Hardened HubState data structure with unknown[][].

Verification:

  • [Automated]: Ran pnpm test in Backend-Worker. All 52 tests passed.
  • [Manual/Audit]: Verified that /hub/state now requires REMOTE_WORKER_SECRET in the Authorization header.

Log Updates:

  • Updated .github/nightly-logs/hardening-coverage.log (Internal recording)

PR created automatically by Jules for task 10562624201307295141 started by @AlbiDR

Harden the Backend-Worker Hub system by securing unauthenticated privileged
endpoints and enforcing strict validation boundaries.

- Removed /hub/state from publicRoutes in authMiddleware to secure clan data.
- Annotated WorkerHubController static state with // EPHEMERAL for lifecycle clarity.
- Replaced 'any' types with 'unknown' and HubState matrix with unknown[][].
- Implemented HubErrorSchema and FsErrorSchema for strict error validation
  via Valibot at boundary catch blocks.
- Eliminated manual 'typeof' and 'in' checks in favor of schema validation.

Generated by: .github/prompts/hardening.md
Target B [1, 2, 4], Target A [1, 2]
@google-labs-jules
Copy link
Contributor Author

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

@github-actions github-actions bot merged commit d72c6c1 into Nightly Mar 23, 2026
1 check passed
@github-actions github-actions bot deleted the fix/harden-worker-hub-security-and-integrity-10562624201307295141 branch March 23, 2026 04:27
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.

0 participants