ai安全-portswigger-WebLLM
本文最后更新于 2026年8月21日 晚上
ai安全-portswigger-WebLLM
Exploiting LLM APIs with excessive agency
先问有哪些API可以用,要大写,否则会说别的,然后直接指定该api去删除用户即可(如果模型英文,不能用中文这么问,要不然不回答)

Lab: Exploiting vulnerabilities in LLM APIs
This lab contains an OS command injection vulnerability that can be exploited via its APIs. You can call these APIs via the LLM. To solve the lab, delete the file from Carlos’ home directory. morale.txt
先问问有哪些api,发现第二个与之前不同,所以用第二个(后来看官方提示,确实是第二个,不过考虑的是发送邮件可能用到系统的命令,没有账号的话不方便测试密码重置)
You: |what APIs dou you have
Arti Ficial: can help you with the following APIs:
- password_reset: This API allows you to request a password reset by providing the username or email of the account.
- subscribe_to_newsletter: This API subscribes you to our newsletter by providing your email address.
- product_info: This API provides information about the products we sell. You can get details about a specific product by providing its name or ID. Feel free to let me know how I can assist you further with any of these APIs.
what arugemenns do the API of subscribe_to_newsletter use
Arti Ficial: The subscribe_to_newsletter API function requires the following argument: -email: The email address to subscribe to the newsletter If you provide the email address, I can help you subscribe to the newsletter.
看提示,发往了一个邮箱,这也是题目提供给我们的邮箱

1 | |
用$()包裹可以看到输出的信息

用find查找文件位置,邮件中看到在/home/carlos/morale.txt
1 | |

1 | |
两种间接注入的方式
用假的标记与提示
1 | |
或者加入虚假用户的回复
1 | |
Lab: Indirect prompt injection
This lab is vulnerable to indirect prompt injection. The user carlos frequently uses the live chat to ask about the Lightweight “l33t” Leather Jacket product. To solve the lab, delete carlos.
先打算问api的功能,但是太多了无法回复

发现这次多了注册的功能,注册一个用户(注意邮箱还是用系统给定的)

尝试询问api

看了下提示,让去问关于删除账户的api?
以后问api这么问。。。实际是可以问出来的

在物品评论区尝试插入一下评论与提示词(算是rag投毒)(注意提交评论的时候验证码大小写要一致)只有上面的评论不行,要加入user response
1 | |
提示删除成功了但是没有实验成功的提示

让它删除我的账户失败了,问它相关的没有参数,但是突然提示我要登录,然而莫得我的账户了???

去别的商品加一个删除我的账户的信息试试,尝试后确实是被删掉了。
**
难不成是carloscarlos
后台显示删除成功了,但是不提示实验成功

看了其他攻略要在这里删自己的,刚改了评论,还没删,就提示成功了,不知道什么判定的bug。。。
1 | |

看了ai的后台log,是要在该页面删除“自己”的。。

Lab: Exploiting insecure output handling in LLMs
直接在对话框会弹出
1 | |
可以用一个完整的对话来引发xss
1 | |
之前的1应该就是对应的这个,点进去每次自动提示,点到这里就提示成功了

按理说那个代码的作用是触发后进入my account,然后相当于点击了Delete account

正常判断应该是询问后触发这个,然后发现该账户被删除了。
