Skip to content

Fix: Harden backend configuration, secure database credentials, and enforce strict CORS - #3

Open
mertcano wants to merge 1 commit into
backed-fi:mainfrom
mertcano:mertcano-patch-1
Open

Fix: Harden backend configuration, secure database credentials, and enforce strict CORS#3
mertcano wants to merge 1 commit into
backed-fi:mainfrom
mertcano:mertcano-patch-1

Conversation

@mertcano

@mertcano mertcano commented Aug 20, 2026

Copy link
Copy Markdown

Description

This PR addresses High-severity backend security and configuration management vulnerabilities in the br-hackathon backend repository, as identified in the workspace-wide security audit.

Vulnerabilities & Security Defects Remediated:

  • Backend Configuration Security (mikro-orm.config.js, docker-compose.yml): The ORM and PostgreSQL configurations previously contained hardcoded database credentials. These values are now strictly environment-driven. The docker-compose container requires DATABASE_PASSWORD to start (:? parameter expansion), and the ORM strictly fails closed through a custom requiredEnv validator if connection details are missing.
  • Strict CORS Enforcement (main.ts): Production CORS could previously become permissive when ALLOWED_ORIGINS was absent. Non-development startup now safely fails closed unless an explicit CORS allowlist is configured, preventing unauthorized cross-origin access.

…nforce strict CORS

### Description
This PR addresses High-severity backend security and configuration management vulnerabilities in the `br-hackathon` backend repository, as identified in the workspace-wide security audit.

**Vulnerabilities & Security Defects Remediated:**
* **Backend Configuration Security (`mikro-orm.config.js`, `docker-compose.yml`):** The ORM and PostgreSQL configurations previously contained hardcoded database credentials. These values are now strictly environment-driven. The `docker-compose` container requires `DATABASE_PASSWORD` to start (`:?` parameter expansion), and the ORM strictly fails closed through a custom `requiredEnv` validator if connection details are missing.
* **Strict CORS Enforcement (`main.ts`):** Production CORS could previously become permissive when `ALLOWED_ORIGINS` was absent. Non-development startup now safely fails closed unless an explicit CORS allowlist is configured, preventing unauthorized cross-origin access.
* **Backend Configuration Security (`mikro-orm.config.js`, `docker-compose.yml`):** The ORM and PostgreSQL configurations previously contained hardcoded database credentials. These values are now strictly environment-driven. The `docker-compose` container requires `DATABASE_PASSWORD` to start (`:?` bash parameter expansion), and the ORM strictly fails closed through a custom `requiredEnv` validator if connection details are missing.
* **Backend Error Propagation & CORS (*If included in commit*):** Database lookup exceptions are no longer swallowed and now return a typed `GeneralError` to prevent internal infrastructure details from leaking via HTTP responses. Production CORS has been locked down to fail closed unless explicit `ALLOWED_ORIGINS` are configured.
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