fix: ensure ALLOWED_CHAT_IDS is correctly passed to prevent telegram chat restriction bypass#897
Conversation
…chat restriction bypass
📝 WalkthroughWalkthroughAdded optional Changes
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
|
✨ Thanks for submitting this PR with a detailed summary to address a potential security issues with Telegram integration. |
Signed-off-by: Carlos Villela <cvillela@nvidia.com>
There was a problem hiding this comment.
🧹 Nitpick comments (1)
src/lib/deploy.test.ts (1)
76-78: Optionally assertALLOWED_CHAT_IDSis emitted exactly once.This would guard against future regressions where the key might reappear via both the generic and conditional paths.
Proposed test hardening
expect(envLines).toContain("TELEGRAM_BOT_TOKEN='123456:telegram-token'"); expect(envLines).toContain("ALLOWED_CHAT_IDS='111,222'"); + expect(envLines.filter((line) => line.startsWith("ALLOWED_CHAT_IDS="))).toHaveLength(1);🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@src/lib/deploy.test.ts` around lines 76 - 78, The test in deploy.test.ts currently checks that envLines contains "ALLOWED_CHAT_IDS='111,222'" but doesn't ensure it appears only once; update the test around the existing expect(envLines).toContain(...) assertions to also assert the key is emitted exactly once by counting occurrences (e.g., filter envLines for entries starting with or matching "ALLOWED_CHAT_IDS=" and expect the count to equal 1) so duplicates from generic and conditional paths are detected.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Nitpick comments:
In `@src/lib/deploy.test.ts`:
- Around line 76-78: The test in deploy.test.ts currently checks that envLines
contains "ALLOWED_CHAT_IDS='111,222'" but doesn't ensure it appears only once;
update the test around the existing expect(envLines).toContain(...) assertions
to also assert the key is emitted exactly once by counting occurrences (e.g.,
filter envLines for entries starting with or matching "ALLOWED_CHAT_IDS=" and
expect the count to equal 1) so duplicates from generic and conditional paths
are detected.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
Run ID: 563177da-3350-4adb-a018-face5c7cdcb7
📒 Files selected for processing (2)
src/lib/deploy.test.tssrc/lib/deploy.ts
…chat restriction bypass (NVIDIA#897) Telegram chat restriction bypass. <!-- markdownlint-disable MD041 --> ## Summary The current implementation fails to propagate the `ALLOWED_CHAT_IDS` environment variable to the Telegram bridge child process. This results in a security bypass where any user can interact with the bot regardless of the whitelist settings. Steps to reproduce: ``` $ env | grep ALLOWED ALLOWED_CHAT_IDS=<redacted> $ nemoclaw start [services] telegram-bridge started (PID 42541) ... $ ps -wwp 42541 -E | grep ALLOWED | echo "missed" missed ``` ## Related Issue [Bug: ALLOWED_CHAT_IDS doesn't work](NVIDIA#896) ## Changes * `ALLOWED_CHAT_IDS` env var propagation ## Type of Change - [x] Code change for a new feature, bug fix, or refactor. - [ ] Code change with doc updates. - [ ] Doc only. Prose changes without code sample modifications. - [ ] Doc only. Includes code sample changes. ## Testing - [x] `npx prek run --all-files` passes (or equivalently `make check`). - [x] `npm test` passes. - [x] `make docs` builds without warnings. (for doc-only changes) ## Checklist ### General - [x] I have read and followed the [contributing guide](https://github.com/NVIDIA/NemoClaw/blob/main/CONTRIBUTING.md). ### Code Changes - [x] Formatters applied — `npx prek run --all-files` auto-fixes formatting (or `make format` for targeted runs). - [ ] Tests added or updated for new or changed behavior. - [x] No secrets, API keys, or credentials committed. - [ ] Doc pages updated for any user-facing behavior changes (new commands, changed defaults, new features, bug fixes that contradict existing docs). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for configuring allowed Telegram chat IDs in deployment credentials. This credential is automatically included in the deployment environment only when a Telegram bot token is configured. * **Tests** * Added test coverage for Telegram credential handling logic. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Carlos Villela <cvillela@nvidia.com>
…chat restriction bypass (NVIDIA#897) Telegram chat restriction bypass. <!-- markdownlint-disable MD041 --> ## Summary The current implementation fails to propagate the `ALLOWED_CHAT_IDS` environment variable to the Telegram bridge child process. This results in a security bypass where any user can interact with the bot regardless of the whitelist settings. Steps to reproduce: ``` $ env | grep ALLOWED ALLOWED_CHAT_IDS=<redacted> $ nemoclaw start [services] telegram-bridge started (PID 42541) ... $ ps -wwp 42541 -E | grep ALLOWED | echo "missed" missed ``` ## Related Issue [Bug: ALLOWED_CHAT_IDS doesn't work](NVIDIA#896) ## Changes * `ALLOWED_CHAT_IDS` env var propagation ## Type of Change - [x] Code change for a new feature, bug fix, or refactor. - [ ] Code change with doc updates. - [ ] Doc only. Prose changes without code sample modifications. - [ ] Doc only. Includes code sample changes. ## Testing - [x] `npx prek run --all-files` passes (or equivalently `make check`). - [x] `npm test` passes. - [x] `make docs` builds without warnings. (for doc-only changes) ## Checklist ### General - [x] I have read and followed the [contributing guide](https://github.com/NVIDIA/NemoClaw/blob/main/CONTRIBUTING.md). ### Code Changes - [x] Formatters applied — `npx prek run --all-files` auto-fixes formatting (or `make format` for targeted runs). - [ ] Tests added or updated for new or changed behavior. - [x] No secrets, API keys, or credentials committed. - [ ] Doc pages updated for any user-facing behavior changes (new commands, changed defaults, new features, bug fixes that contradict existing docs). <!-- This is an auto-generated comment: release notes by coderabbit.ai --> ## Summary by CodeRabbit * **New Features** * Added support for configuring allowed Telegram chat IDs in deployment credentials. This credential is automatically included in the deployment environment only when a Telegram bot token is configured. * **Tests** * Added test coverage for Telegram credential handling logic. <!-- end of auto-generated comment: release notes by coderabbit.ai --> Signed-off-by: Carlos Villela <cvillela@nvidia.com> Co-authored-by: Carlos Villela <cvillela@nvidia.com>
Telegram chat restriction bypass.
Summary
The current implementation fails to propagate the
ALLOWED_CHAT_IDSenvironment variable to the Telegram bridge child process. This results in a security bypass where any user can interact with the bot regardless of the whitelist settings.Steps to reproduce:
Related Issue
Bug: ALLOWED_CHAT_IDS doesn't work
Changes
ALLOWED_CHAT_IDSenv var propagationType of Change
Testing
npx prek run --all-filespasses (or equivalentlymake check).npm testpasses.make docsbuilds without warnings. (for doc-only changes)Checklist
General
Code Changes
npx prek run --all-filesauto-fixes formatting (ormake formatfor targeted runs).Summary by CodeRabbit
New Features
Tests