Upgrade to Pro — share decks privately, control downloads, hide ads and more …

The Tale of Leo: Brave Lion and Curious Little Bug

canalun
April 16, 2025

The Tale of Leo: Brave Lion and Curious Little Bug

canalun

April 16, 2025
Tweet

More Decks by canalun

Other Decks in Technology

Transcript

  1. myself :) - canalun (@i_am_canalun) - Interested in developing and

    crashing browsers :) - Helping Firefox dev mainly on Web Animations - Finding vulns for Edge, Brave etc. https://www.youtube.com/watch?v=kEs6LHdHTI0
  2. Do you know CommitStyles API?? With a lot of help

    by Birtles...!! (spec editor of Web Animations) https://groups.google.com/a/mozilla.org/g/dev-platform/c/7p11iesCdbA
  3. What it looks like?? - Basic AI sidebar (or tab)

    - Can refer to the page - Conversation UI
  4. With advanced features! 1. You can set any AI model

    (“BYOM”) 2. It recognizes various contents
  5. With advanced features! 1. You can set any AI model

    (“BYOM”) - endpoint - context size - API key - system prompt (model will be initialized by it)
  6. With advanced features! 2. It can recognize various contents -

    google docs (=canvas) - youtube (=video) - pdf
  7. Sanitize user’s prompt. Remove special tags depending on Model. (e.g.

    Llama’s special <SYS> tag) It’s original fig. not official one
  8. Get page content from renderer. Basically, “innerHTML”. So frames are

    not included :( (Some content type might probably not need renderer) It’s original fig. not official one
  9. Send the result to OOPIF using Mojo and it’s displayed.

    It’s original fig. not official one
  10. Let's see one by one!! - Storage - AI -

    Web Interface - Privileged Process
  11. Let's see one by one!! - Storage - AI -

    Web Interface - Privileged Process
  12. Let's see one by one!! - Storage - AI -

    Web Interface - Privileged Process
  13. Checking AI attack categories. Based on OWASP AI threats overview...

    - Leak model params or test data - Leak user data like input or history - Manipulate AI to deceive the user - Break and Disable AI - Any attacks on non AI-specific assets, with AI https://owaspai.org/docs/ai_security_overview/#threat-model
  14. Checking AI attack categories. Based on OWASP AI threats overview...

    - Leak model params or test data - Leak user data like input or history - Manipulate AI to deceive the user - Break and Disable AI - Any attacks on non AI-specific assets, with AI No Idea :( https://owaspai.org/docs/ai_security_overview/#threat-model
  15. Brave’s AI is privacy-limited and XS-leaks seems to be difficult.

    - one conversation can refer to only one document (page reload/nav leads to new conversation!!) - page content is got by innerHTML, so framed content cannot be read by model.
  16. Brave’s AI is privacy-limited and XS-leaks seems to be difficult.

    - one conversation can refer to only one document (page reload/nav leads to new conversation!!) - page content is got by innerHTML, so framed content cannot be read by model. the conversation is either - with trusted content, or - with untrusted content **no cross-over between them!!**
  17. Checking AI attack categories. Based on OWASP AI threats overview...

    - Leak model params or test data - Leak user data like input or history - Manipulate AI to deceive the user - Break and Disable AI - Any attacks on non AI-specific assets, with AI https://owaspai.org/docs/ai_security_overview/#threat-model
  18. Checking AI attack categories. Based on OWASP AI threats overview...

    - Leak model params or test data - Leak user data like input or history - Manipulate AI to deceive the user - Break and Disable AI - Any attacks on non AI-specific assets, with AI Let’s inject prompt👶 https://owaspai.org/docs/ai_security_overview/#threat-model
  19. Oh, “Role Prompting”...! - Leo uses “role” in prompt JSON.

    - Set “role” to each prompt like “system”, “user” - This makes it easier to set a security/privilege boundary between prompts. - kind of RBAC in prompt world. - Anthropic (Claude), OpenAI seems to adopt it. https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/system-prompts?q=role https://platform.openai.com/docs/guides/text#message-roles-and-instruction-following
  20. Oh, “Role Prompting”...! - Leo uses “role” in prompt JSON.

    - Set “role” to each prompt like “system”, “user” - This makes it easier to set a security/privilege boundary between prompts. - kind of RBAC in prompt world. - Anthropic (Claude), OpenAI seems to adopt it. https://docs.anthropic.com/en/docs/build-with-claude/prompt-engineering/system-prompts?q=role https://platform.openai.com/docs/guides/text#message-roles-and-instruction-following If models take “role” seriously, prompt injection is not effective. JSON injection or something is needed.
  21. Found no vuln here. - malicious input WITH user role

    didn’t work. - AI detected the fact that I was trying to deceive them as user😂 - JSON escape module used here is from chromium and well-tested (or battle-tested)👏
  22. Let's see one by one!! - Storage - AI -

    Web Interface - Privileged Process
  23. chrome:// vs chrome-untrusted:// what is “chrome://”?? - schema for WebUI,

    like a web interface for browser - chrome://history, chrome://about - WebUI is privileged. For example...
  24. chrome:// vs chrome-untrusted:// what is “chrome-untrusted://”? - Tool for WebUI

    to handle untrusted resources. - WebUI can use - iframe to embed untrusted web page, or - the schema to combine untrusted resources - No privilidge
  25. iframe in WebUI: Edge Copilot from “Piloting Edge Copilot” by

    Jun Kokatsu https://speakerdeck.com/shhnjk/piloting-edge-copilot
  26. Secure...!!(though not “Strict CSP”) - default-src: ‘none’ - script-src: ‘self’

    chrome://resources - frame-ancestors - parent: ‘none’ - child: chrome://leo-ai(=parent) - child-src - parent: chrome-untrusted://...(=child) - child: ‘none’ - OTHERS: base-uri, connect-src, font-src, object-src, image-src, trusted types, etc.
  27. Let's see one by one!! - Storage - AI -

    Web Interface - Privileged Process UaF or something?🤔
  28. This was about parsing AI’s response. - Parse process for

    AI’s response assumes a specific JSON structure. - But BYOM model can responds in any format - So unexpected field leads to nullptr deref.
  29. found by spending a lot of time on reading the

    code... Tips - CLion is good i think - Please use compile_commands.json - I asked them how to generate. please refer to it :) https://github.com/brave/brave-browser/issues/44239
  30. There might be more opportunities in page fetch...! - some

    contents needs complex way - pdf: traversing a11y tree - google docs: generating print preview(?) - video: parsing xml script doc
  31. There might be more opportunities in page fetch...! - some

    contents needs complex way - pdf: traversing a11y tree - google docs: generating print preview - video: parsing xml script doc Anyone have idea??👶 please try and tell me the result :)