🇰🇷 한글 설명
theshit 쉘 명령어 수정 도구의 0.1.1 버전 이전에서 사용자 쓰기 가능 위치의 Python 규칙 파일을 소유권 검증 없이 로드하는 특권 상승 취약점입니다. sudo나 root 권한 실행 시 로컬 공격자가 악의적인 규칙 파일을 통해 root 권한으로 임의 코드 실행이 가능합니다.
💡 쉬운 설명
theshit을 sudo로 실행하면 홈 폴더의 설정 파일을 제대로 검사하지 않아, 공격자가 악성 파일을 몰래 놓으면 root 권한으로 악의적인 명령어가 실행됩니다. 로컬 사용자만 공격 가능하지만 root 권한을 획득할 수 있습니다.
🇺🇸 원문 (English)
theshit is a command-line utility that automatically detects and fixes common mistakes in shell commands. Prior to version 0.1.1, the application loads custom Python rules and configuration files from user-writable locations (e.g., `~/.config/theshit/`) without validating ownership or permissions when executed with elevated privileges. If the tool is invoked with `sudo` or otherwise runs with an effective UID of root, it continues to trust configuration files originating from the unprivileged user's environment. This allows a local attacker to inject arbitrary Python code via a malicious rule or configuration file, which is then executed with root privileges. Any system where this tool is executed with elevated privileges is affected. In environments where the tool is permitted to run via `sudo` without a password (`NOPASSWD`), a local unprivileged user can escalate privileges to root without additional interaction. The issue has been fixed in version 0.1.1. The patch introduces strict ownership and permission checks for all configuration files and custom rules. The application now enforces that rules are only loaded if they are owned by the effective user executing the tool. When executed with elevated privileges (`EUID=0`), the application refuses to load any files that are not owned by root or that are writable by non-root users. When executed as a non-root user, it similarly refuses to load rules owned by other users. This prevents both vertical and horizontal privilege escalation via execution of untrusted code. If upgrading is not possible, users should avoid executing the application with `sudo` or as the root user. As a temporary mitigation, ensure that directories containing custom rules and configuration files are owned by root and are not writable by non-root users. Administrators may also audit existing custom rules before running the tool with elevated privileges.
📍 영향받는 시스템
theshit < 0.1.1
⚔️ 공격 벡터
로컬 사용자가 ~/.config/theshit/ 디렉토리에 악성 Python 규칙 파일 작성 후 도구를 sudo로 실행할 때 로드됨
🛡️ 대응 방법
theshit을 0.1.1 이상으로 업그레이드하거나 임시 조치로 규칙 디렉토리를 root 소유로 변경 및 sudo 실행 제한
🔧 검증 코드
버전이 0.1.1 이상이면 안전하고 그 미만이면 취약함
pip show theshit 2>/dev/null | grep Version || dpkg -l theshit 2>/dev/null | tail -1 | awk '{print $3}'