CVE-2024-7008 - STAR-2024-0039 - Calibre Reflected Cross-Site Scripting (XSS)
Affects | Status | Importance | Assigned to | Milestone | |
---|---|---|---|---|---|
calibre |
Fix Released
|
Undecided
|
Unassigned |
Bug Description
# CVE-2024-7008 - STAR-2024-0039 - Calibre Reflected Cross-Site Scripting (XSS)
## Summary:
| **Product** | Calibre |
| -------
| **Vendor** | Calibre |
| **Severity** | Medium |
| **Affected Versions** | <= 7.15.0 (latest version as of writing) |
| **Tested Versions** | 7.15.0 |
| **CVE Identifier** | CVE-2024-7008 |
| **CWE Classification(s)** | CWE-79 Improper Neutralization of Input During Web Page Generation (XSS or 'Cross-site Scripting') |
| **CAPEC Classification(s)** | CAPEC-591 Reflected XSS |
## CVSS3.1 Scoring System:
**Base Score:** 5.4 (Medium)
**Vector String:** `CVSS:3.
| **Metric** | **Value** |
| -------
| **Attack Vector (AV)** | Network |
| **Attack Complexity (AC)** | Low |
| **Privileges Required (PR)** | None |
| **User Interaction (UI)** | Required |
| **Scope (S)** | Unchanged |
| **Confidentiality (C)** | Low |
| **Integrity (I)** | Low |
| **Availability (A)** | None |
## Product Overview:
Calibre is a cross-platform free and open-source suite of e-book software. Calibre supports organizing existing e-books into virtual libraries, displaying, editing, creating and converting e-books, as well as syncing e-books with a variety of e-readers. Editing books is supported for EPUB and AZW3 formats. Books in other formats like MOBI must first be converted to those formats, if they are to be edited. Calibre also has a large collection of community contributed plugins.
Calibre also offers a powerful content server feature. This allows users to share their Calibre libraries over the internet, making it easy to access your e-book collection from anywhere, at any time.
## Vulnerability Summary:
It is possible to inject arbitrary JavaScript code into the `/browse` endpoint of the Calibre content server, allowing an attacker to craft a URL that when clicked by a victim, will execute the attacker's JavaScript code in the context of the victim's browser. If the Calibre server is running with authentication enabled and the victim is logged in at the time, this can be used to cause the victim to perform actions on the Calibre server on behalf of the attacker.
## Vulnerability Details:
In `src/calibre/
```python
@endpoint(
def browse(ctx, rd, rest):
if rest.startswith
# implementation of https:/
# redirect old server book URLs to new URLs
redirect = ctx.url_for(None) + '#book_id=' + rest[5:] + "&panel=
from lxml import etree as ET
return html(ctx, rd, endpoint,
else:
raise HTTPRedirect(
```
As can be seen from the code, if a user navigates to a URL of the form `/browse/book/123`, the server will insert the content after `book/` straight into a variable `redirect`, followed by directly concatenating this variable into a meta refresh tag at [1] and a JavaScript redirect at [2] through the use of lxml's `etree.XML()` function, without performing any sanitisation. The injection at [1] was not found to be exploitable as most attempts would result in malformed XML that would cause etree to raise an exception. However, the injection at [2] was found to be exploitable, due to lxml's behaviour of expanding the `"` entity into `"` before serialising the XML tree into a string.
```
>>> from lxml import etree
>>> etree.tostring(
b'<script>
```
Thus, we can use `"` to escape the string assignment and inject arbitrary JavaScript code into the page. This can be used to perform a reflected cross-site scripting attack.
## Proof-of-Concept:
Browse to the following URL, where CALIBRE_SERVER is the address of the Calibre server:
`http://
Note that the alert is executed in the context of the Calibre server's origin:
](https:/
STAR Labs requests that Calibre use the above reserved CVE identifiers when referencing the vulnerabilities presented in this report instead of requesting for new CVE identifiers (e.g. via MITRE or GitHub Security Advisory) to prevent having duplicate CVE records.
The scheduled disclosure date is _**27 Nov, 2024**_. Disclosure at an earlier date is also possible if agreed upon by all parties.
information type: | Private Security → Public Security |
Fixed in branch master. The fix will be in the next release. calibre is usually released every alternate Friday.