Skip to content

πŸ›‘οΈ Sentinel: [CRITICAL] Fix missing authentication on Zalo service#39

Open
mbsebada wants to merge 2 commits into
mainfrom
sentinel/fix-zalo-service-auth-5162267206061211968
Open

πŸ›‘οΈ Sentinel: [CRITICAL] Fix missing authentication on Zalo service#39
mbsebada wants to merge 2 commits into
mainfrom
sentinel/fix-zalo-service-auth-5162267206061211968

Conversation

@mbsebada

Copy link
Copy Markdown
Owner

🚨 Severity: CRITICAL
πŸ’‘ Vulnerability: The Node.js Zalo integration microservice (examples/rentagent_vn/zalo-service/index.js) was entirely unauthenticated. This allowed any local service, or anyone able to bypass the API proxy, to call internal endpoints (such as /message/send or /auth/cookie) directly and perform sensitive actions (like sending messages from the user's account) without proper authorization.
🎯 Impact: Unauthorized internal or SSRF-exploited access to the Zalo messaging service, leading to arbitrary message sending on behalf of the integrated account.
πŸ”§ Fix: Added authentication middleware to the Express app. It verifies an x-api-key header against the ZALO_SERVICE_API_KEY environment variable. The /health check remains exempt from authentication. It uses crypto.timingSafeEqual with matching Buffer instances to securely compare keys and avoid timing side-channels, and fails securely (HTTP 500) if the environment variable is not configured. The Python proxy client (examples/rentagent_vn/api/routes/zalo.py) was also updated to pass this header.
βœ… Verification: Verified by checking code changes, linting specific changed files via ruff check, and validating the Python test suite. Code review passed and journal updated.


PR created automatically by Jules for task 5162267206061211968 started by @mbsebada

Co-authored-by: mbsebada <19614248+mbsebada@users.noreply.github.com>
@google-labs-jules

Copy link
Copy Markdown

πŸ‘‹ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

πŸ’‘ Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: fe89da6747

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with πŸ‘.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +28 to +30
if (!expectedApiKey) {
console.error("[Zalo Service Security] ZALO_SERVICE_API_KEY is not configured!");
return res.status(500).json({ error: "Internal server error" });

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve default local startup when API key is unset

This middleware turns every non-/health request into HTTP 500 when ZALO_SERVICE_API_KEY is absent, but the current local startup path (examples/rentagent_vn/run_all.py) does not set that variable and api/routes/zalo.py defaults the forwarded key to "". In that default environment, all Zalo auth/message flows now fail immediately, which is a functional regression for the example stack rather than a graceful security hardening path. Consider wiring a shared dev key during local startup (or failing fast at process boot with explicit setup instructions) so the example remains runnable.

Useful? React with πŸ‘Β / πŸ‘Ž.

Co-authored-by: mbsebada <19614248+mbsebada@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