Skip to content

Security: Unauthenticated API Endpoints Expose and Allow Modification of Sensitive Configuration#1

Open
maptoan wants to merge 1 commit intomasterfrom
contribai/fix/security/unauthenticated-api-endpoints-expose-and
Open

Security: Unauthenticated API Endpoints Expose and Allow Modification of Sensitive Configuration#1
maptoan wants to merge 1 commit intomasterfrom
contribai/fix/security/unauthenticated-api-endpoints-expose-and

Conversation

@maptoan
Copy link
Copy Markdown
Owner

@maptoan maptoan commented Mar 29, 2026

Problem

The /config GET and POST endpoints in src/api/server.py allow any unauthenticated client to read and modify the application's config.yaml file. This file contains highly sensitive information such as api_keys (e.g., GEMINI_API_KEY) and critical file paths (input.novel_path, output.output_path, ocr.tesseract_cmd, ocr.poppler_path).

An attacker can exploit this to:

  1. Retrieve API keys: Gain unauthorized access to external services.
  2. Alter application behavior: Modify any configuration setting, potentially disrupting service or enabling other attacks.
  3. Command Injection: If ocr.tesseract_cmd or ocr.poppler_path are modified to point to a malicious executable or contain injected commands, and the application later executes these, it could lead to arbitrary code execution on the server.
  4. Path Traversal: If file paths like input.novel_path or output.output_path are modified to point outside intended directories (e.g., /etc/passwd or /tmp/malicious.sh), the application could be tricked into reading or writing to arbitrary locations on the filesystem.

The tasks/todo_create_web_ui_20260225_1900.md explicitly mentions "ConfigForm: Linh hoạt cho phép sửa API Keys, Model, Paths," confirming the intent to expose these, but without mentioning authentication.

Severity: critical
File: src/api/server.py

Solution

Implement robust authentication and authorization mechanisms (e.g., API keys, OAuth2, session-based authentication) for all sensitive API endpoints, especially /config. Only authorized users should be able to access or modify configuration.

Example (conceptual, requires full auth implementation):

Changes

  • src/api/server.py (modified)

Testing

  • Existing tests pass
  • Manual review completed
  • No new warnings/errors introduced

…dification of sensitive configuration

The `/config` GET and POST endpoints in `src/api/server.py` allow any unauthenticated client to read and modify the application's `config.yaml` file. This file contains highly sensitive information such as `api_keys` (e.g., `GEMINI_API_KEY`) and critical file paths (`input.novel_path`, `output.output_path`, `ocr.tesseract_cmd`, `ocr.poppler_path`).

An attacker can exploit this to:
1.  **Retrieve API keys**: Gain unauthorized access to external services.
2.  **Alter application behavior**: Modify any configuration setting, potentially disrupting service or enabling other attacks.
3.  **Command Injection**: If `ocr.tesseract_cmd` or `ocr.poppler_path` are modified to point to a malicious executable or contain injected commands, and the application later executes these, it could lead to arbitrary code execution on the server.
4.  **Path Traversal**: If file paths like `input.novel_path` or `output.output_path` are modified to point outside intended directories (e.g., `/etc/passwd` or `/tmp/malicious.sh`), the application could be tricked into reading or writing to arbitrary locations on the filesystem.

The `tasks/todo_create_web_ui_20260225_1900.md` explicitly mentions "ConfigForm: Linh hoạt cho phép sửa API Keys, Model, Paths," confirming the intent to expose these, but without mentioning authentication.


Affected files: server.py

Signed-off-by: toanmap <174589430+maptoan@users.noreply.github.com>
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