网友用GPT 5.3 AI写脚本清理文件,因1个符号导致磁盘清空

IT之家
Feb 21

IT之家 2 月 21 日消息,网友 u/Former-Airport-1099 昨日(2 月 20 日)在 Reddit 社区发帖,在使用 GPT 5.3 Codex 生成脚本清理电脑中的垃圾文件,结果由于一个微小的语法错误,导致整块硬盘被格式化。

IT之家援引博文介绍,该用户原本希望通过 AI 编写的自动化脚本,批量删除项目中名为“pycache”的 Python 临时文件夹。然而,脚本运行后,原本应被清理的临时文件毫发无损,用户 F 盘中的所有数据却瞬间删除。

技术复盘显示,这场灾难的根源在于 AI 混淆 Windows 系统中不同解释器规则。ChatGPT 生成的脚本试图通过 PowerShell 调用 CMD 命令 rmdir。

在处理文件路径中的特殊字符时,AI 习惯性地使用了反斜杠(\)作为转义符。然而,在 PowerShell 环境中,正确的转义符应当是反引号(`)。这一细微的差异导致命令行工具将原本用于转义的符号误读为路径分隔符,进而将删除目标指向了当前驱动器的根目录。

该事件同时也暴露了 Windows 命令行环境的脆弱性。脚本中不仅包含了错误的路径描述,还因 AI 的“贴心”设计加入了“无确认强制删除”参数。

当 PowerShell 将错误的字符传递给 CMD 命令后,这种跨解释器的指令翻译缺乏必要的安全屏障。系统未能识别出这是一个明显的逻辑错误,而是机械地执行了针对根目录的强制删除指令,最终酿成大祸。

Disclaimer: Investing carries risk. This is not financial advice. The above content should not be regarded as an offer, recommendation, or solicitation on acquiring or disposing of any financial products, any associated discussions, comments, or posts by author or other users should not be considered as such either. It is solely for general information purpose only, which does not consider your own investment objectives, financial situations or needs. TTM assumes no responsibility or warranty for the accuracy and completeness of the information, investors should do their own research and may seek professional advice before investing.

Most Discussed

  1. 1
     
     
     
     
  2. 2
     
     
     
     
  3. 3
     
     
     
     
  4. 4
     
     
     
     
  5. 5
     
     
     
     
  6. 6
     
     
     
     
  7. 7
     
     
     
     
  8. 8
     
     
     
     
  9. 9
     
     
     
     
  10. 10