import { useEffect, useState } from 'react'; import { AlertTriangle } from 'lucide-react'; import { api } from '../api'; import type { HealthStatus } from '../types'; import { Button } from './ui/button'; import { Checkbox } from './ui/checkbox'; import { Dialog, DialogContent, DialogDescription, DialogHeader, DialogTitle } from './ui/dialog'; import { toast } from './ui/sonner'; const STORAGE_KEY = 'meshcore_security_warning_acknowledged'; function readAcknowledgedState(): boolean { if (typeof window === 'undefined') { return false; } try { return window.localStorage.getItem(STORAGE_KEY) === 'true'; } catch { return false; } } function writeAcknowledgedState(): void { if (typeof window === 'undefined') { return; } try { window.localStorage.setItem(STORAGE_KEY, 'true'); } catch { // Best effort only; the warning will continue to show if localStorage is unavailable. } } interface SecurityWarningModalProps { health: HealthStatus | null; } export function SecurityWarningModal({ health }: SecurityWarningModalProps) { const [acknowledged, setAcknowledged] = useState(readAcknowledgedState); const [confirmedRisk, setConfirmedRisk] = useState(false); const [disablingBots, setDisablingBots] = useState(false); const [botsDisabledLocally, setBotsDisabledLocally] = useState(false); const shouldWarn = health !== null && health.bots_disabled !== true && health.basic_auth_enabled !== true && !botsDisabledLocally && !acknowledged; useEffect(() => { if (!shouldWarn) { setConfirmedRisk(false); } }, [shouldWarn]); useEffect(() => { if (health?.bots_disabled !== true) { setBotsDisabledLocally(false); } }, [health?.bots_disabled, health?.bots_disabled_source]); if (!shouldWarn) { return null; } return ( event.preventDefault()} onInteractOutside={(event) => event.preventDefault()} >
Unprotected bot execution is enabled

Bots are not disabled, and app-wide Basic Auth is not configured.

Without one of those protections, or another access-control layer in front of RemoteTerm, anyone on your local network who can reach this app can run Python code on the computer hosting this instance via the bot system.

This is only safe on protected or isolated networks with appropriate access control. If your network is untrusted or later compromised, this setup may expose the host system to arbitrary code execution.

To reduce that risk, run the server with environment variables to either disable bots with{' '} MESHCORE_DISABLE_BOTS=true {' '} or enable the built-in login with{' '} MESHCORE_BASIC_AUTH_USERNAME {' '} /{' '} MESHCORE_BASIC_AUTH_PASSWORD . Another external auth or access-control system is also acceptable.

If you just want a temporary safety measure while you learn the system, you can use the button below to disable bots until the server restarts. That is only a temporary guard; permanent protection through Basic Auth or env-based bot disablement is still encouraged.

); }