Skip to content

Fix: Harden safe-events-service authentication, dynamic execution, and environment defaults - #2

Open
magqqgq wants to merge 1 commit into
etherlinkcom:mainfrom
magqqgq:magqqgq-patch-1
Open

Fix: Harden safe-events-service authentication, dynamic execution, and environment defaults#2
magqqgq wants to merge 1 commit into
etherlinkcom:mainfrom
magqqgq:magqqgq-patch-1

Conversation

@magqqgq

@magqqgq magqqgq commented Aug 21, 2026

Copy link
Copy Markdown

Description

This PR addresses critical authentication, dynamic execution, and environment configuration vulnerabilities within the safe-events-service repository.

Vulnerabilities & Security Defects Remediated:

  • Authentication and Session Security (src/admin/adminjs.ts, src/config/required-secret.ts): AdminJS previously used literal, hardcoded values for cookie and session secrets. The implementation now strictly requires separate environment-provided values with minimum length constraints and placeholder rejection. Uninitialized sessions are also disabled to avoid unnecessary storage.
  • Authentication Fail-Open Behavior (src/auth/basic-auth.guard.ts): Missing SSE_AUTH_TOKEN previously disabled authentication. The guard has been updated to fail closed: it now rejects requests when the token is missing, too short, or a placeholder, accepting only an exact Basic <token> header. Regression tests cover these flows.
  • Dynamic Execution and Type Safety (src/admin/adminjs.ts): AdminJS modules were previously loaded through eval and cast to Promise<any>. This has been refactored to use native dynamic import(), removing arbitrary generated-code evaluation and securing the untyped import boundary.
  • Production Docker Defaults (.env.docker, .env.sample): The Docker environment previously used default credentials (admin@safe / password) while declaring NODE_ENV=production. These defaults are now explicit placeholders, requiring AdminJS and SSE secrets to be supplied securely via deployment configuration.

…d environment defaults

### Description
This PR addresses critical authentication, dynamic execution, and environment configuration vulnerabilities within the `safe-events-service` repository.

**Vulnerabilities & Security Defects Remediated:**
* **Authentication and Session Security (`src/admin/adminjs.ts`, `src/config/required-secret.ts`):** AdminJS previously used literal, hardcoded values for cookie and session secrets. The implementation now strictly requires separate environment-provided values with minimum length constraints and placeholder rejection. Uninitialized sessions are also disabled to avoid unnecessary storage.
* **Authentication Fail-Open Behavior (`src/auth/basic-auth.guard.ts`):** Missing `SSE_AUTH_TOKEN` previously disabled authentication. The guard has been updated to fail closed: it now rejects requests when the token is missing, too short, or a placeholder, accepting only an exact `Basic <token>` header. Regression tests cover these flows.
* **Dynamic Execution and Type Safety (`src/admin/adminjs.ts`):** AdminJS modules were previously loaded through `eval` and cast to `Promise<any>`. This has been refactored to use native dynamic `import()`, removing arbitrary generated-code evaluation and securing the untyped import boundary.
* **Production Docker Defaults (`.env.docker`, `.env.sample`):** The Docker environment previously used default credentials (`admin@safe` / `password`) while declaring `NODE_ENV=production`. These defaults are now explicit placeholders, requiring AdminJS and SSE secrets to be supplied securely via deployment configuration.
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.

1 participant