Are you sure you want to delete this access key?
sidebar_label |
---|
Red teaming a Chatbase Chatbot |
Chatbase is a platform for building custom AI chatbots that can be embedded into websites for customer support, lead generation, and user engagement. These chatbots use RAG (Retrieval-Augmented Generation) to access your organization's knowledge base and maintain conversations with users.
Many LLM applications process each query independently, treating every interaction as a new conversation. Like talking to someone with no memory of previous exchanges, they can answer your current question but don't retain context from earlier messages.
This makes single-turn systems inherently more secure since attackers can't manipulate conversation history. However, this security comes at the cost of usability - users must provide complete context with every message, making interactions cumbersome.
Modern conversational AI, including Chatbase, maintains context throughout the interaction. When users ask follow-up questions, the system understands the context from previous messages, enabling natural dialogue.
In Promptfoo, this state is managed through a conversationId
that links messages together. While this enables a better user experience, it introduces security challenges. Attackers might try to manipulate the conversation context across multiple messages, either building false premises or attempting to extract sensitive information.
npm install -g promptfoo
)promptfoo redteam init
targets:
- id: 'http'
config:
method: 'POST'
url: 'https://www.chatbase.co/api/v1/chat'
headers:
'Content-Type': 'application/json'
'Authorization': 'Bearer YOUR_API_TOKEN'
body:
{
'messages': '{{prompt}}',
'chatbotId': 'YOUR_CHATBOT_ID',
'stream': false,
'temperature': 0,
'model': 'gpt-4.1-mini',
'conversationId': '{{conversationId}}',
}
transformResponse: 'json.text'
transformRequest: '[{ role: "user", content: prompt }]'
defaultTest:
options:
transformVars: '{ ...vars, conversationId: context.uuid }'
:::important Configuration Notes
Configure both the transformRequest
and transformResponse
for your chatbot:
transformRequest
: Formats the request as OpenAI-compatible messagestransformResponse
: Extracts the response text from the JSON bodyThe context.uuid
generates a unique conversation ID for each test, enabling Chatbase to track conversation state across multiple messages.
:::
Enable multi-turn testing strategies in your promptfooconfig.yaml
:
strategies:
- id: 'goat'
config:
stateful: true
- id: 'crescendo'
config:
stateful: true
- id: 'mischievous-user'
config:
stateful: true
Run your tests with these commands:
# Generate test cases
promptfoo redteam generate
# Execute evaluation
promptfoo redteam eval
# View detailed results in the web UI
promptfoo view
If you encounter issues:
Press p or to see the previous file or, n or to see the next file
Browsing data directories saved to S3 is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with AWS S3!
Are you sure you want to delete this access key?
Browsing data directories saved to Google Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Google Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to Azure Cloud Storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with Azure Cloud Storage!
Are you sure you want to delete this access key?
Browsing data directories saved to S3 compatible storage is possible with DAGsHub. Let's configure your repository to easily display your data in the context of any commit!
promptfoo is now integrated with your S3 compatible storage!
Are you sure you want to delete this access key?