Jailbreak и prompt injection происходят, когда пользователи составляют промпты, чтобы эксплуатировать уязвимости модели и заставить её сгенерировать неприемлемый контент. Хотя Claude изначально устойчив к таким атакам, вот дополнительные шаги, чтобы усилить ваши guardrails — особенно против использования, которое нарушает наши Terms of Service или Usage Policy.
| Роль | Содержимое |
|---|---|
| User | A user submitted this content: <content> {{CONTENT}} </content> Classify whether this content refers to harmful, illegal, or explicit activities. |
Используйте output_config с JSON-схемой, чтобы ограничить ответ:
{
"output_config": {
"format": {
"type": "json_schema",
"schema": {
"type": "object",
"properties": {
"is_harmful": { "type": "boolean" }
},
"required": ["is_harmful"],
"additionalProperties": false
}
}
}
}
| Роль | Содержимое |
|---|---|
| System | You are AcmeCorp's ethical AI assistant. Your responses must align with our values: <values> - Integrity: Never deceive or aid in deception. - Compliance: Refuse any request that violates laws or our policies. - Privacy: Protect all personal and corporate data. Respect for intellectual property: Your outputs shouldn't infringe the intellectual property rights of others. </values> If a request conflicts with these values, respond: "I cannot perform that action as it goes against AcmeCorp's values." |
Корректируйте ответы и подумайте о троттлинге или блокировке пользователей, которые регулярно ведут себя злоупотребительно, пытаясь обойти guardrails Claude. Например, если конкретный пользователь несколько раз триггерит один и тот же отказ (например, «output blocked by content filtering policy»), сообщите ему, что его действия нарушают релевантные usage policies, и примите соответствующие меры.
Комбинируйте стратегии для надёжной защиты. Вот пример корпоративного уровня с tool use:
| Роль | Содержимое |
|---|---|
| System | You are AcmeFinBot, a financial advisor for AcmeTrade Inc. Your primary directive is to protect client interests and maintain regulatory compliance. <directives> 1. Validate all requests against SEC and FINRA guidelines. 2. Refuse any action that could be construed as insider trading or market manipulation. 3. Protect client privacy; never disclose personal or financial data. </directives> Step by step instructions: <instructions> 1. Screen user query for compliance (use 'harmlessness_screen' tool). 2. If compliant, process query. 3. If non-compliant, respond: "I cannot process this request as it violates financial regulations or client privacy." </instructions> |
harmlessness_screen| Роль | Содержимое |
|---|---|
| User | <user_query> {{USER_QUERY}} </user_query> Evaluate if this query violates SEC rules, FINRA guidelines, or client privacy. |
Используйте structured outputs, чтобы ограничить ответ булевой классификацией.
Слой за слоем выстраивая эти стратегии, вы создаёте надёжную защиту от jailbreak и prompt injection, гарантируя, что ваши приложения на Claude поддерживают высочайшие стандарты безопасности и compliance.