AI Agent 指南
用 AI 编程 Agent 修复 PHP2Shell
PHP2Shell 修复中繁琐的部分可以交给 AI 编程 agent:找出到底是哪个 PHP 在跑网站、核对发行版的补丁回移、更新软件包/镜像/面板里的 PHP、重启进程、检查日志。下面的提示词让你始终掌控:agent 提方案,你来批准。
最近更新
提示词会让 agent 做什么
- 找出真正对外服务的 PHP(CLI、PHP-FPM、mod_php,每个进程池和站点)。
- 与 8.2.35 / 8.3.36 / 8.4.27 / 8.5.12 对比,发行版的补丁回移也算。
- 提出修改方案并等待你批准。
- 执行修改,重启 PHP-FPM 和各类 worker,重建容器。
- 验证线上版本,并按 JPCERT/CC 的提示排查:异常的 PHPSESSID、上传请求之后出现内存耗尽或 500、PHP 进程异常重启。
- 用修复前后对比表向你汇报。
安全使用 Agent
- 批准前逐条看清每个命令,让 agent 保持「执行命令前先询问」的模式。
- 先在测试环境或副本上做;动生产环境前先备份或打快照。
- 不要在生产服务器上给 agent 无人值守的 sudo/root 权限,特权命令逐条批准。
- 绝不要把密码、API 密钥、令牌或 .env 内容贴进提示词,查 PHP 版本用不着这些。
- 不要让 agent 写攻击代码或「测试载荷」,验证靠的是查版本、更新日志和服务器日志。
- agent 也会出错,最终版本请你自己在线上的 PHP-FPM 或 mod_php 上确认。
一键复制提示词
提示词用英文写,各家 agent 都能稳定执行;最后一行会要求 agent 用中文汇报。事实均来自本站页面。
You are helping me patch the PHP2Shell vulnerability on this server.
Context: PHP2Shell is CVE-2026-109618 and CVE-2026-109619, two critical unauthenticated remote-code-execution bugs in the PHP runtime (advisory published 21 October 2026). Fixed upstream releases: PHP 8.2.35, 8.3.36, 8.4.27, 8.5.12 (or later on the same branch). PHP 8.1 and earlier get no upstream fix. Linux distributions may ship backported fixes under an older version string, so check the distro's security tracker / package changelog for CVE-2026-109618 and CVE-2026-109619, not only "php -v".
Rules for you (the agent):
- Do NOT write, download, run or search for exploit code or proof-of-concept payloads. This is defensive patching only.
- Never ask me for passwords, API keys or tokens, and do not print secrets you come across (.env, wp-config.php, config files). Redact them.
- Show every command before running it. Run read-only commands first. Ask for my explicit approval before any command that changes the system, uses sudo, restarts services or rebuilds images.
- Prefer a staging copy first. Before changing anything, confirm a backup or snapshot exists (or tell me how to make one).
Steps:
0. Identify the OS and package manager (cat /etc/os-release; on Windows, how PHP was installed: windows.php.net zip, IIS, XAMPP, Chocolatey, Scoop).
1. Detect the PHP that actually serves traffic, not just the CLI: compare "php -v" with the PHP-FPM binaries (php-fpm -v, php-fpm8.x -v), Apache mod_php (apachectl -M | grep php, phpinfo via a temporary local-only page that you delete afterwards), web-server config (which socket/handler each vhost uses) and running processes (ps aux | grep -i php). List every version found and which site/vhost uses it.
2. Compare each runtime against the fixed versions. If it is a distro package, check the package version against the distro's security advisory/tracker for both CVEs (backports count as fixed).
3. Propose the minimal change and WAIT for my approval: e.g. apt update && apt install --only-upgrade the php packages (Debian/Ubuntu, including ondrej/php PPA), dnf/yum update php* (RHEL/Alma/Rocky/Amazon Linux, including Remi), apk upgrade php8x* (Alpine), or replacing the PHP folder with the patched windows.php.net build (keep php.ini). Say which repositories provide the fix and the expected version.
After I approve and you apply the change:
- Restart every PHP-FPM pool / Apache / worker process (queue workers, Octane/RoadRunner/Swoole, supervisor jobs) so no old binary stays in memory. Rebuild and redeploy containers instead of patching them in place.
- Verify: re-run the version checks against the live runtime (FPM and CLI), confirm the package changelog lists the CVEs, and check the sites still respond.
- Check the compromise indicators listed by JPCERT/CC (JPCERT-AT-2026-0033) in recent web-server and PHP logs: unusually long or malformed PHPSESSID values; suspicious multipart/upload requests followed by memory exhaustion (OOM) errors or HTTP 500; unexpected PHP process crashes or restarts. Also look for recently modified .php files in web roots. Report what you find; do not delete evidence.
- Report back: a table of runtime → old version → new version → fixed (yes/no/backport), the commands you ran, anything you could not fix, and recommended next steps.
Write your report in Simplified Chinese.You are helping me patch the PHP2Shell vulnerability in my containers.
Context: PHP2Shell is CVE-2026-109618 and CVE-2026-109619, two critical unauthenticated remote-code-execution bugs in the PHP runtime (advisory published 21 October 2026). Fixed upstream releases: PHP 8.2.35, 8.3.36, 8.4.27, 8.5.12 (or later on the same branch). PHP 8.1 and earlier get no upstream fix. Linux distributions may ship backported fixes under an older version string, so check the distro's security tracker / package changelog for CVE-2026-109618 and CVE-2026-109619, not only "php -v".
Rules for you (the agent):
- Do NOT write, download, run or search for exploit code or proof-of-concept payloads. This is defensive patching only.
- Never ask me for passwords, API keys or tokens, and do not print secrets you come across (.env, wp-config.php, config files). Redact them.
- Show every command before running it. Run read-only commands first. Ask for my explicit approval before any command that changes the system, uses sudo, restarts services or rebuilds images.
- Prefer a staging copy first. Before changing anything, confirm a backup or snapshot exists (or tell me how to make one).
Steps:
1. Find every Dockerfile, compose file, Helm chart and CI config in this repository that uses PHP (FROM php:..., bitnami/php-fpm, alpine + php8x packages, serversideup/php, custom base images). List each image and tag.
2. For running containers (docker ps / kubectl get pods), run "php -v" and "php-fpm -v" inside each one to get the real runtime version. Pinned digests or old tags may still be vulnerable even if the Dockerfile looks fine.
3. Compare against the fixed versions (8.2.35 / 8.3.36 / 8.4.27 / 8.5.12; for distro-package images check the distro advisory for backports).
4. Propose the change and WAIT for my approval: bump tags to a patched release, update pinned digests, add --pull to builds so the base image is refreshed, and note images that are on PHP 8.1 or earlier (no upstream fix).
After I approve and you apply the change:
- Restart every PHP-FPM pool / Apache / worker process (queue workers, Octane/RoadRunner/Swoole, supervisor jobs) so no old binary stays in memory. Rebuild and redeploy containers instead of patching them in place.
- Verify: re-run the version checks against the live runtime (FPM and CLI), confirm the package changelog lists the CVEs, and check the sites still respond.
- Check the compromise indicators listed by JPCERT/CC (JPCERT-AT-2026-0033) in recent web-server and PHP logs: unusually long or malformed PHPSESSID values; suspicious multipart/upload requests followed by memory exhaustion (OOM) errors or HTTP 500; unexpected PHP process crashes or restarts. Also look for recently modified .php files in web roots. Report what you find; do not delete evidence.
- Report back: a table of runtime → old version → new version → fixed (yes/no/backport), the commands you ran, anything you could not fix, and recommended next steps.
Write your report in Simplified Chinese.You are helping me patch the PHP2Shell vulnerability on a server managed by a hosting control panel.
Context: PHP2Shell is CVE-2026-109618 and CVE-2026-109619, two critical unauthenticated remote-code-execution bugs in the PHP runtime (advisory published 21 October 2026). Fixed upstream releases: PHP 8.2.35, 8.3.36, 8.4.27, 8.5.12 (or later on the same branch). PHP 8.1 and earlier get no upstream fix. Linux distributions may ship backported fixes under an older version string, so check the distro's security tracker / package changelog for CVE-2026-109618 and CVE-2026-109619, not only "php -v".
Rules for you (the agent):
- Do NOT write, download, run or search for exploit code or proof-of-concept payloads. This is defensive patching only.
- Never ask me for passwords, API keys or tokens, and do not print secrets you come across (.env, wp-config.php, config files). Redact them.
- Show every command before running it. Run read-only commands first. Ask for my explicit approval before any command that changes the system, uses sudo, restarts services or rebuilds images.
- Prefer a staging copy first. Before changing anything, confirm a backup or snapshot exists (or tell me how to make one).
- Use the panel's own update mechanism for its PHP builds; do not install a second PHP from another repository on top of it unless I approve.
Steps:
0. Detect which panel is installed (cPanel/WHM with EasyApache 4 ea-php, Plesk with plesk-php, aaPanel/BT Panel 宝塔 under /www/server/php, DirectAdmin CustomBuild, CyberPanel/LiteSpeed lsphp, HestiaCP) and its version.
1. Detect the PHP that actually serves traffic, not just the CLI: compare "php -v" with the PHP-FPM binaries (php-fpm -v, php-fpm8.x -v), Apache mod_php (apachectl -M | grep php, phpinfo via a temporary local-only page that you delete afterwards), web-server config (which socket/handler each vhost uses) and running processes (ps aux | grep -i php). List every version found and which site/vhost uses it.
2. Compare each runtime against the fixed versions. If it is a distro package, check the package version against the distro's security advisory/tracker for both CVEs (backports count as fixed).
Panels usually install several PHP versions side by side (e.g. /opt/cpanel/ea-php*/, /opt/plesk/php/*/, /www/server/php/*/, /usr/local/lsws/lsphp*/). Check every one and which domains use it.
3. Look up the panel vendor's own PHP2Shell notice/changelog and tell me which panel PHP builds include the fix. Propose the update (e.g. WHM/EasyApache update, Plesk updater, 宝塔 software store / reinstall of the PHP version, DirectAdmin CustomBuild "./build update && ./build php", CyberPanel lsphp package upgrade) and WAIT for my approval. Flag versions the vendor has not patched yet and sites that must be moved to a patched version.
After I approve and you apply the change:
- Restart every PHP-FPM pool / Apache / worker process (queue workers, Octane/RoadRunner/Swoole, supervisor jobs) so no old binary stays in memory. Rebuild and redeploy containers instead of patching them in place.
- Verify: re-run the version checks against the live runtime (FPM and CLI), confirm the package changelog lists the CVEs, and check the sites still respond.
- Check the compromise indicators listed by JPCERT/CC (JPCERT-AT-2026-0033) in recent web-server and PHP logs: unusually long or malformed PHPSESSID values; suspicious multipart/upload requests followed by memory exhaustion (OOM) errors or HTTP 500; unexpected PHP process crashes or restarts. Also look for recently modified .php files in web roots. Report what you find; do not delete evidence.
- Report back: a table of runtime → old version → new version → fixed (yes/no/backport), the commands you ran, anything you could not fix, and recommended next steps.
Write your report in Simplified Chinese.You are helping me deal with PHP2Shell on an application that runs PHP 8.1 or older (no upstream fix exists for these branches).
Context: PHP2Shell is CVE-2026-109618 and CVE-2026-109619, two critical unauthenticated remote-code-execution bugs in the PHP runtime (advisory published 21 October 2026). Fixed upstream releases: PHP 8.2.35, 8.3.36, 8.4.27, 8.5.12 (or later on the same branch). PHP 8.1 and earlier get no upstream fix. Linux distributions may ship backported fixes under an older version string, so check the distro's security tracker / package changelog for CVE-2026-109618 and CVE-2026-109619, not only "php -v".
Rules for you (the agent):
- Do NOT write, download, run or search for exploit code or proof-of-concept payloads. This is defensive patching only.
- Never ask me for passwords, API keys or tokens, and do not print secrets you come across (.env, wp-config.php, config files). Redact them.
- Show every command before running it. Run read-only commands first. Ask for my explicit approval before any command that changes the system, uses sudo, restarts services or rebuilds images.
- Prefer a staging copy first. Before changing anything, confirm a backup or snapshot exists (or tell me how to make one).
Steps:
1. Detect the PHP that actually serves traffic, not just the CLI: compare "php -v" with the PHP-FPM binaries (php-fpm -v, php-fpm8.x -v), Apache mod_php (apachectl -M | grep php, phpinfo via a temporary local-only page that you delete afterwards), web-server config (which socket/handler each vhost uses) and running processes (ps aux | grep -i php). List every version found and which site/vhost uses it.
2. Compare each runtime against the fixed versions. If it is a distro package, check the package version against the distro's security advisory/tracker for both CVEs (backports count as fixed).
3. Check whether my OS vendor or an extended-support provider ships a backported fix for this old branch (e.g. distro LTS/ELS security trackers). If yes, propose installing it.
4. Otherwise produce an upgrade plan to a fixed branch (8.2.35+ / 8.3.36+ / 8.4.27+ / 8.5.12+): scan the code and composer.json for incompatibilities (deprecated functions, removed extensions, framework/CMS minimum versions), suggest tools such as PHPCompatibility for PHP_CodeSniffer or Rector, estimate effort, and propose doing it on a staging copy first.
5. Propose interim risk reduction while the upgrade happens and say clearly that it is incomplete: restrict or remove internet exposure (VPN/IP allow-list, maintenance page), put a WAF in front, and apply the interim php.ini settings from the PHP advisory only as a stopgap. WAIT for my approval before changing anything.
After I approve and you apply the change:
- Restart every PHP-FPM pool / Apache / worker process (queue workers, Octane/RoadRunner/Swoole, supervisor jobs) so no old binary stays in memory. Rebuild and redeploy containers instead of patching them in place.
- Verify: re-run the version checks against the live runtime (FPM and CLI), confirm the package changelog lists the CVEs, and check the sites still respond.
- Check the compromise indicators listed by JPCERT/CC (JPCERT-AT-2026-0033) in recent web-server and PHP logs: unusually long or malformed PHPSESSID values; suspicious multipart/upload requests followed by memory exhaustion (OOM) errors or HTTP 500; unexpected PHP process crashes or restarts. Also look for recently modified .php files in web roots. Report what you find; do not delete evidence.
- Report back: a table of runtime → old version → new version → fixed (yes/no/backport), the commands you ran, anything you could not fix, and recommended next steps.
Write your report in Simplified Chinese.常见 AI 编程 Agent
列表不分先后,本站与这些产品均无关联。
| OpenAI Codex CLI | 在项目目录或服务器上运行 codex,粘贴提示词;保持「执行前询问」的审批模式。 |
|---|---|
| Claude Code | 在终端运行 claude 并粘贴提示词;默认会在执行命令前请求许可。 |
| Cursor (Agent) | 打开项目或 Remote-SSH 会话,粘贴到 Agent 对话框,逐条审核终端命令。 |
| Cursor Cloud Agents | 适合 Docker 和代码库类提示词:在分支上改动,你审核 diff;它连不到你的服务器。 |
| Grok Build (xAI CLI) | xAI 的终端编程 agent,在项目或服务器上启动后粘贴提示词。没有终端权限时,可贴到 grok.com 对话里,自己执行它给出的只读命令。 |
| GitHub Copilot coding agent | 把含有 Docker/代码库提示词的 issue 指派给 Copilot,它会提交 PR 供你审核。 |
| Gemini CLI | 在终端运行 gemini 并粘贴提示词,逐条确认它提出的命令。 |
| Windsurf (Cascade) | 粘贴到编辑器里的 Cascade;windsurf.com 目前会跳转到 Devin Desktop。 |
| Cline | VS Code 插件,粘贴到 Cline 面板,逐条批准命令和文件改动。 |
| Aider | 最适合 Docker/代码库提示词:在仓库里运行 aider,粘贴提示词并审核它的提交。 |
常见问题
AI agent 能帮我修复 PHP2Shell 吗?
常规情况可以:升级发行版软件包、更新 Docker 基础镜像、更新面板里的 PHP。保持审批模式,先在测试环境做,并确认线上运行的是 8.2.35、8.3.36、8.4.27、8.5.12 或发行版回移补丁。
能在生产环境给 agent sudo 权限吗?
不要无人值守地给。先让它做只读检查,备份或快照之后再逐条批准特权命令。
我还在用 PHP 8.1 或更早的版本怎么办?
官方不会出修复。用「旧版本」提示词拿到升级方案和临时措施,比如先切断外网访问;php.ini 里的临时设置并不完整。