Skip to content

Commit 4529c87

Browse files
authored
Autolink gh-NNNNN and CVE-NNNN-NNNNN (#151)
1 parent 667c822 commit 4529c87

3 files changed

Lines changed: 68 additions & 13 deletions

File tree

‎content/posts/python-31022-31117/index.md‎

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -30,29 +30,29 @@ Python 3.12.15 is also a source-only security release, with security support con
3030

3131
## Security content in all five releases
3232

33-
* [gh-158446](https://github.com/python/cpython/issues/158446): Fix crashes or incorrect output when formatting float or complex values with precision close to INT_MAX.
34-
* [CVE-2026-19553](https://www.cve.org/CVERecord?id=CVE-2026-19553) — [gh-156793](https://github.com/python/cpython/issues/156793): `ssl.SSLContext.wrap_bio()` now validates its `server_side`, `server_hostname`, and `session` arguments. `asyncio` also validates TLS `server_hostname` arguments. On Python 3.10, 3.11, and 3.12, missing hostnames with `check_hostname` enabled emit `DeprecationWarning` for compatibility; they raise `ValueError` on Python 3.13 and later.
35-
* [gh-157953](https://github.com/python/cpython/issues/157953): Update bundled libexpat to version 2.8.5.
36-
* [CVE-2026-15310](https://www.cve.org/CVERecord?id=CVE-2026-15310) — [gh-156002](https://github.com/python/cpython/issues/156002): Bound `zipfile` decompression per read for bzip2 and LZMA members, and for Zstandard members on Python 3.14, preventing unbounded allocations from small compressed members. Third-party decompressors supplied by monkey-patching `_get_decompressor()` that lack `needs_input` and two-argument `decompress()` remain vulnerable.
37-
* [CVE-2026-19672](https://www.cve.org/CVERecord?id=CVE-2026-19672) — [gh-155999](https://github.com/python/cpython/issues/155999): Prevent tarfile extraction filters from creating directories outside the destination for paths that leave it and then return.
38-
* [CVE-2026-19445](https://www.cve.org/CVERecord?id=CVE-2026-19445) — [gh-156293](https://github.com/python/cpython/issues/156293): Fix an ssl crash when an SNI callback switches contexts and the original callback context is no longer referenced.
39-
* [CVE-2026-17084](https://www.cve.org/CVERecord?id=CVE-2026-17084) — [gh-155292](https://github.com/python/cpython/issues/155292): Restrict stringprep and the IDNA codec to Unicode codepoint attributes defined by RFC 3454.
40-
* [CVE-2026-15806](https://www.cve.org/CVERecord?id=CVE-2026-15806) — [gh-155694](https://github.com/python/cpython/issues/155694): Scope urllib.request HTTPPasswordMgr credentials by URL scheme to prevent HTTPS credentials from being used for matching HTTP URLs.
33+
* gh-158446: Fix crashes or incorrect output when formatting float or complex values with precision close to INT_MAX.
34+
* CVE-2026-19553 — gh-156793: `ssl.SSLContext.wrap_bio()` now validates its `server_side`, `server_hostname`, and `session` arguments. `asyncio` also validates TLS `server_hostname` arguments. On Python 3.10, 3.11, and 3.12, missing hostnames with `check_hostname` enabled emit `DeprecationWarning` for compatibility; they raise `ValueError` on Python 3.13 and later.
35+
* gh-157953: Update bundled libexpat to version 2.8.5.
36+
* CVE-2026-15310 — gh-156002: Bound `zipfile` decompression per read for bzip2 and LZMA members, and for Zstandard members on Python 3.14, preventing unbounded allocations from small compressed members. Third-party decompressors supplied by monkey-patching `_get_decompressor()` that lack `needs_input` and two-argument `decompress()` remain vulnerable.
37+
* CVE-2026-19672 — gh-155999: Prevent tarfile extraction filters from creating directories outside the destination for paths that leave it and then return.
38+
* CVE-2026-19445 — gh-156293: Fix an ssl crash when an SNI callback switches contexts and the original callback context is no longer referenced.
39+
* CVE-2026-17084 — gh-155292: Restrict stringprep and the IDNA codec to Unicode codepoint attributes defined by RFC 3454.
40+
* CVE-2026-15806 — gh-155694: Scope urllib.request HTTPPasswordMgr credentials by URL scheme to prevent HTTPS credentials from being used for matching HTTP URLs.
4141

4242
## Additional security content by version
4343

4444
### Python 3.10.22, 3.11.17, 3.12.15 and 3.13.16
4545

46-
* [CVE-2026-82049](https://www.cve.org/CVERecord?id=CVE-2026-82049) — [gh-157190](https://github.com/python/cpython/issues/157190): Fix a tarfile extraction-filter vulnerability involving hard links to symbolic links that could expose files outside the destination and change their permissions or modification times. Python 3.14 and later were already protected because `os.link()` follows symbolic links since Python 3.14.0b1 ([gh-81793](https://github.com/python/cpython/issues/81793)).
47-
* [CVE-2026-87910](https://www.cve.org/CVERecord?id=CVE-2026-87910) — [gh-157265](https://github.com/python/cpython/issues/157265): Apply tarfile extraction filters when a link falls back to extracting an archive member, skipping members rejected by the filter.
46+
* CVE-2026-82049 — gh-157190: Fix a tarfile extraction-filter vulnerability involving hard links to symbolic links that could expose files outside the destination and change their permissions or modification times. Python 3.14 and later were already protected because `os.link()` follows symbolic links since Python 3.14.0b1 (gh-81793).
47+
* CVE-2026-87910 — gh-157265: Apply tarfile extraction filters when a link falls back to extracting an archive member, skipping members rejected by the filter.
4848

4949
### Python 3.13.16 and 3.14.8
5050

51-
* [gh-158010](https://github.com/python/cpython/issues/158010): Update bundled OpenSSL to [3.5.9](https://openssl-library.org/news/secadv/20260929.txt). In Python 3.13.16 this applies to Windows, macOS and Android, moving from OpenSSL 3.0.21 to the 3.5 LTS series. In Python 3.14.8 it applies to Windows, macOS, Android and iOS. The source-only Python 3.10–3.12 releases do not bundle OpenSSL.
51+
* gh-158010: Update bundled OpenSSL to [3.5.9](https://openssl-library.org/news/secadv/20260929.txt). In Python 3.13.16 this applies to Windows, macOS and Android, moving from OpenSSL 3.0.21 to the 3.5 LTS series. In Python 3.14.8 it applies to Windows, macOS, Android and iOS. The source-only Python 3.10–3.12 releases do not bundle OpenSSL.
5252

5353
### Python 3.10.22
5454

55-
* [gh-149018](https://github.com/python/cpython/issues/149018): Improve protection against XML hash-flooding attacks in `xml.parsers.expat` and `xml.etree.ElementTree` when compiled with libexpat 2.8.0 or later.
55+
* gh-149018: Improve protection against XML hash-flooding attacks in `xml.parsers.expat` and `xml.etree.ElementTree` when compiled with libexpat 2.8.0 or later.
5656

5757
This XML hash-flooding protection was already included in Python 3.11.16.
5858

‎src/layouts/BlogPostLayout.astro‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ const groupMeta: Record<string, { label: string; order: number }> = {
3737
"gh-repo": { label: "Repositories", order: 2 },
3838
"gh-user": { label: "People", order: 3 },
3939
"pypi": { label: "Packages", order: 4 },
40+
"cve": { label: "Security", order: 5 },
4041
};
4142
4243
const sortedGroups = [...refGroups.entries()]
@@ -195,6 +196,7 @@ const sortedGroups = [...refGroups.entries()]
195196
type === "gh-repo" && "bg-zinc-100 text-zinc-700 hover:bg-zinc-200 dark:bg-zinc-800 dark:text-zinc-300 dark:hover:bg-zinc-700",
196197
type === "gh-user" && "bg-zinc-100 text-zinc-700 hover:bg-zinc-200 dark:bg-zinc-800 dark:text-zinc-300 dark:hover:bg-zinc-700",
197198
type === "pypi" && "bg-emerald-50 text-emerald-700 hover:bg-emerald-100 dark:bg-emerald-900/20 dark:text-emerald-300 dark:hover:bg-emerald-900/40",
199+
type === "cve" && "bg-rose-50 text-rose-700 hover:bg-rose-100 dark:bg-rose-900/20 dark:text-rose-300 dark:hover:bg-rose-900/40",
198200
]}
199201
target="_blank"
200202
rel="noopener noreferrer"

‎src/plugins/remark-python-refs.ts‎

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,12 @@
1313
* - GitHub users/orgs (github.com/NAME — exactly 1 segment, not reserved)
1414
* - CVE references (nvd.nist.gov/vuln/detail/CVE-YYYY-NNNNN)
1515
* - Python releases (python.org/downloads/release/python-XXXX/)
16+
*
17+
* Bare "gh-NNNN" and "CVE-YYYY-NNNN" text (not already inside a link
18+
* or heading) is autolinked and rendered as a badge.
1619
*/
1720
import type { Root, Link, Paragraph, PhrasingContent } from "mdast";
18-
import { visit } from "unist-util-visit";
21+
import { SKIP, visit } from "unist-util-visit";
1922
import {
2023
pythonIcon,
2124
docsIcon,
@@ -35,6 +38,14 @@ const DOCS = /^https?:\/\/docs\.python\.org\//i;
3538
const PYPI = /^https?:\/\/pypi\.org\/project\/([^/]+)\/?/i;
3639
const GH_ISSUE = /^https?:\/\/github\.com\/([\w.-]+)\/([\w.-]+)\/(issues|pull)\/(\d+)\/?/i;
3740
const CVE = /^https?:\/\/nvd\.nist\.gov\/vuln\/detail\/(CVE-[\d-]+)\/?/i;
41+
42+
/**
43+
* Bare references in plain text that get autolinked (outside links,
44+
* headings and code):
45+
* - "gh-156293" → python/cpython issue
46+
* - "CVE-2026-19445" → cve.org record
47+
*/
48+
const BARE_REF = /\b(?:(CVE-\d{4}-\d{4,})|gh-(\d+))\b/g;
3849
const PY_RELEASE = /^https?:\/\/(?:www\.)?python\.org\/downloads\/release\/(python-[\w.]+)\/?/i;
3950
const GITHUB =
4051
/^https?:\/\/github\.com\/([\w.-]+)(?:\/([\w.-]+))?\/?$/i;
@@ -330,6 +341,48 @@ export default function remarkPythonRefs() {
330341
}
331342
});
332343

344+
// Pass 3: Autolink bare gh-NNNN issue refs and CVE IDs in text → badges
345+
visit(tree, (node: any, index, parent: any) => {
346+
// Don't touch text that is already a link (or a reference definition),
347+
// or headings — Astro builds heading ids from text nodes only, so
348+
// injecting HTML there would change the anchor slug.
349+
if (
350+
node.type === "link" ||
351+
node.type === "linkReference" ||
352+
node.type === "definition" ||
353+
node.type === "heading"
354+
) {
355+
return SKIP;
356+
}
357+
if (node.type !== "text" || index == null || !parent) return;
358+
359+
const value: string = node.value;
360+
const parts: any[] = [];
361+
let lastIndex = 0;
362+
BARE_REF.lastIndex = 0;
363+
let m: RegExpExecArray | null;
364+
while ((m = BARE_REF.exec(value)) !== null) {
365+
if (m.index > lastIndex) {
366+
parts.push({ type: "text", value: value.slice(lastIndex, m.index) });
367+
}
368+
const [label, cve, ghNum] = m;
369+
const match: Match = cve
370+
? { type: "cve", icon: shieldIcon, label, url: `https://www.cve.org/CVERecord?id=${cve}` }
371+
: { type: "gh-issue", icon: issueIcon, label, url: `https://github.com/python/cpython/issues/${ghNum}` };
372+
collectRef(match.type, match.label, match.url);
373+
parts.push({ type: "html", value: buildBadgeHtml(match) });
374+
lastIndex = m.index + m[0].length;
375+
}
376+
if (parts.length === 0) return;
377+
if (lastIndex < value.length) {
378+
parts.push({ type: "text", value: value.slice(lastIndex) });
379+
}
380+
381+
parent.children.splice(index, 1, ...parts);
382+
// Continue after the nodes we just inserted
383+
return index + parts.length;
384+
});
385+
333386
// Expose collected references via remarkPluginFrontmatter
334387
if (!file.data.astro) file.data.astro = {};
335388
if (!file.data.astro.frontmatter) file.data.astro.frontmatter = {};

0 commit comments

Comments
 (0)