Fix: Harden safe-events-service authentication, dynamic execution, and environment defaults - #2
Open
magqqgq wants to merge 1 commit into
Open
Fix: Harden safe-events-service authentication, dynamic execution, and environment defaults#2magqqgq wants to merge 1 commit into
magqqgq wants to merge 1 commit into
Conversation
…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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
This PR addresses critical authentication, dynamic execution, and environment configuration vulnerabilities within the
safe-events-servicerepository.Vulnerabilities & Security Defects Remediated:
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.src/auth/basic-auth.guard.ts): MissingSSE_AUTH_TOKENpreviously 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 exactBasic <token>header. Regression tests cover these flows.src/admin/adminjs.ts): AdminJS modules were previously loaded throughevaland cast toPromise<any>. This has been refactored to use native dynamicimport(), removing arbitrary generated-code evaluation and securing the untyped import boundary..env.docker,.env.sample): The Docker environment previously used default credentials (admin@safe/password) while declaringNODE_ENV=production. These defaults are now explicit placeholders, requiring AdminJS and SSE secrets to be supplied securely via deployment configuration.