Skip to content

Dictionary stylesheet functionality provides unexpected vector for injecting markup (incl. JavaScript code) into Anki flashcards

Low
jamesmaa published GHSA-g3p8-q34q-x686 Apr 17, 2025

Package

Yomitan (Anki)

Affected versions

24.6.21.0 to 24.12.27.0

Patched versions

24.12.30.0

Description

Summary

Yomitan dictionaries may include a CSS stylesheet file, styles.css. If HTML is written in this file, then Anki flashcards created from the dictionary data will contain this markup in a non-sanitized format. Opening such flashcards in Anki will cause the markup to render and embedded <script> blocks to execute.

Details

styles.css functionality was added in PR #1080

The text content of the styles.css file (loaded from a dictionary ZIP archive) is set to the textContent property of a style node within the Yomitan popup. This prevents any HTML text from being rendered within the browser by the Yomitan web extension. However, when this text is sent to Anki during flashcard creation, it is not sanitized in a similar manner.

PoC

Example styles.css
span[data-sc-content="registered-symbol"] {
    vertical-align: super;
    font-size: 0.6em;
}

div[data-sc-content="attribution"] {
    font-size: 0.7em;
    text-align: right;
}

</style>
<script>
alert("hello");
</script>
<style>

Dictionary file with this stylesheet: malicious_dictionary.zip

Steps to reproduce:

  1. Install latest versions of Anki, Yomitan, AnkiConnect
  2. Import malicious dictionary into Yomitan
  3. Setup Anki Card template in Yomitan, setting Deck to "Default," Model to "Basic," Front to "{expression}" and Back to "{glossary}"
  4. Create an Anki flashcard for the term 付箋
  5. Open the "Default" deck to review the newly created card in Anki. Click the "Show Answer button," and observe the "hello" JavaScript alert as Anki renders the card's glossary.
Image of "hello" popup in Anki

hello

Impact

Anki flashcards are displayed in a sandbox, and the potential for harm is generally understood to be low. User-created Anki flashcard decks are commonly shared online and often contain JavaScript code. So the likelihood of a maliciously crafted Yomitan dictionary causing harm through this route is probably low. However, the behavior doesn't seem to be expected or desirable.

Severity

Low

CVSS overall score

This score calculates overall vulnerability severity from 0 to 10 and is based on the Common Vulnerability Scoring System (CVSS).
/ 10

CVSS v3 base metrics

Attack vector
Adjacent
Attack complexity
High
Privileges required
None
User interaction
Required
Scope
Unchanged
Confidentiality
Low
Integrity
None
Availability
None

CVSS v3 base metrics

Attack vector: More severe the more the remote (logically and physically) an attacker can be in order to exploit the vulnerability.
Attack complexity: More severe for the least complex attacks.
Privileges required: More severe if no privileges are required.
User interaction: More severe when no user interaction is required.
Scope: More severe when a scope change occurs, e.g. one vulnerable component impacts resources in components beyond its security scope.
Confidentiality: More severe when loss of data confidentiality is highest, measuring the level of data access available to an unauthorized user.
Integrity: More severe when loss of data integrity is the highest, measuring the consequence of data modification possible by an unauthorized user.
Availability: More severe when the loss of impacted component availability is highest.
CVSS:3.1/AV:A/AC:H/PR:N/UI:R/S:U/C:L/I:N/A:N

CVE ID

No known CVE

Weaknesses

No CWEs

Credits