summaryrefslogtreecommitdiff
path: root/external_plugins/telegram/server.ts
diff options
context:
space:
mode:
authorKenneth Lien <kenneth@anthropic.com>2026-03-20 10:48:05 -0700
committerGitHub <noreply@github.com>2026-03-20 10:48:05 -0700
commit562a27feec2c60bc94a3b58ae1b926382ae836bf (patch)
treef31a1ef2d1fd34d77189b8455bd9481b5f909a9e /external_plugins/telegram/server.ts
parentd687c591f4192f11195783078b60ef3648c3eeab (diff)
parent8140fbad22814b99ad56e1161a43ec203da669d8 (diff)
Merge pull request #811 from anthropics/kenneth/chmod-env-files
Lock telegram/discord .env files to owner (chmod 600)
Diffstat (limited to 'external_plugins/telegram/server.ts')
-rw-r--r--external_plugins/telegram/server.ts4
1 files changed, 3 insertions, 1 deletions
diff --git a/external_plugins/telegram/server.ts b/external_plugins/telegram/server.ts
index e2265b8d..8acd52a2 100644
--- a/external_plugins/telegram/server.ts
+++ b/external_plugins/telegram/server.ts
@@ -18,7 +18,7 @@ import {
import { Bot, InputFile, type Context } from 'grammy'
import type { ReactionTypeEmoji } from 'grammy/types'
import { randomBytes } from 'crypto'
-import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync, renameSync, realpathSync } from 'fs'
+import { readFileSync, writeFileSync, mkdirSync, readdirSync, rmSync, statSync, renameSync, realpathSync, chmodSync } from 'fs'
import { homedir } from 'os'
import { join, extname, sep } from 'path'
@@ -30,6 +30,8 @@ const ENV_FILE = join(STATE_DIR, '.env')
// Load ~/.claude/channels/telegram/.env into process.env. Real env wins.
// Plugin-spawned servers don't get an env block — this is where the token lives.
try {
+ // Token is a credential — lock to owner. No-op on Windows (would need ACLs).
+ chmodSync(ENV_FILE, 0o600)
for (const line of readFileSync(ENV_FILE, 'utf8').split('\n')) {
const m = line.match(/^(\w+)=(.*)$/)
if (m && process.env[m[1]] === undefined) process.env[m[1]] = m[2]