public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Benjamin A. Beasley <code@musicinmybrain.net>
To: git-commits@fedoraproject.org
Subject: [rpms/rust-onefetch] epel10.3: Backport fix for CVE-2026-100866 from 3.0.0
Date: Thu, 08 Oct 2026 11:28:24 GMT [thread overview]
Message-ID: <179145890474.1.13820636150249551769.rpms-rust-onefetch-ec7de03495e1@fedoraproject.org> (raw)
A new commit has been pushed.
Repo : rpms/rust-onefetch
Branch : epel10.3
Commit : ec7de03495e18b5f5a97598447d710b21b64dbc4
Author : Benjamin A. Beasley <code@musicinmybrain.net>
Date : 2026-10-08T12:09:41+01:00
Stats : +277/-0 in 3 file(s)
URL : https://src.fedoraproject.org/rpms/rust-onefetch/c/ec7de03495e18b5f5a97598447d710b21b64dbc4?branch=epel10.3
Log:
Backport fix for CVE-2026-100866 from 3.0.0
---
diff --git a/1829.patch b/1829.patch
new file mode 100644
index 0000000..44ee927
--- /dev/null
+++ b/1829.patch
@@ -0,0 +1,256 @@
+From ea83302efb7cc18188bb061a574bde163ab3927c Mon Sep 17 00:00:00 2001
+From: Gogs <gogs@fake.local>
+Date: Fri, 7 Aug 2026 22:39:50 +0800
+Subject: [PATCH 1/4] fix: strip control characters from info field values
+
+Version and Project (repo name) fall back to a package.json/Cargo.toml
+manifest field when git tags/remote are absent, and those values were
+styled and written to the terminal with no filtering of control
+characters. A manifest field has no character restrictions, unlike a
+git tag/ref, so a crafted manifest could inject terminal escape
+sequences into onefetch's own output.
+
+Adds sanitize_for_display in InfoField::style_value, the single choke
+point every field's value already passes through, so the fix covers
+every manifest-derived field, not just version.
+---
+ src/info/utils/info_field.rs | 15 +++++++++++++--
+ 1 file changed, 13 insertions(+), 2 deletions(-)
+
+diff --git a/src/info/utils/info_field.rs b/src/info/utils/info_field.rs
+index 52d69011c..99fc0bb99 100644
+--- a/src/info/utils/info_field.rs
++++ b/src/info/utils/info_field.rs
+@@ -2,6 +2,18 @@ use crate::{info::utils::get_style, ui::text_colors::TextColors};
+ use owo_colors::OwoColorize;
+ use std::fmt;
+
++/// Replaces control characters (which can include terminal escape sequences)
++/// with the Unicode replacement character, since some field values (a
++/// project manifest's version, name, description, or license, for example)
++/// come from data with no character restrictions and shouldn't be trusted
++/// to display as-is. `\n` is preserved since some fields intentionally span
++/// multiple lines.
++fn sanitize_for_display(s: &str) -> String {
++ s.chars()
++ .map(|c| if c != '\n' && c.is_control() { '\u{FFFD}' } else { c })
++ .collect()
++}
++
+ #[typetag::serialize]
+ pub trait InfoField {
+ fn value(&self) -> String;
+@@ -46,8 +58,7 @@ pub trait InfoField {
+ return None;
+ }
+ let style = get_style(false, text_colors.info);
+- let styled_lines: Vec<String> = self
+- .value()
++ let styled_lines: Vec<String> = sanitize_for_display(&self.value())
+ .lines()
+ .map(|line| format!("{}", line.style(style)))
+ .collect();
+
+From 4af537777ff6b65959e50cdb258de728d6bbdf68 Mon Sep 17 00:00:00 2001
+From: Gogs <gogs@fake.local>
+Date: Sun, 9 Aug 2026 17:52:04 +0800
+Subject: [PATCH 2/4] test(info_field): add unit tests for sanitize_for_display
+
+Covers the control-byte-to-replacement-character behavior directly
+(including an OSC title-set style payload), confirms newlines and
+normal printable text are left untouched, and adds a style_value-level
+test exercising the sanitizer through the same path real field values
+take.
+---
+ src/info/utils/info_field.rs | 36 ++++++++++++++++++++++++++++++++++++
+ 1 file changed, 36 insertions(+)
+
+diff --git a/src/info/utils/info_field.rs b/src/info/utils/info_field.rs
+index 99fc0bb99..51586ef8f 100644
+--- a/src/info/utils/info_field.rs
++++ b/src/info/utils/info_field.rs
+@@ -131,4 +131,40 @@ mod test {
+ info.write_styled(&mut buffer, false, &colors).unwrap();
+ assert_eq!(buffer, "", "It should not write anything");
+ }
++
++ #[test]
++ fn test_sanitize_for_display_strips_control_chars() {
++ // ESC ] 0 ; PWNED BEL, an OSC title-set sequence
++ let input = "1.0.0\u{1b}]0;PWNED\u{07}";
++ let sanitized = sanitize_for_display(input);
++ assert_eq!(sanitized, "1.0.0\u{FFFD}]0;PWNED\u{FFFD}");
++ assert!(!sanitized.contains('\u{1b}'));
++ assert!(!sanitized.contains('\u{07}'));
++ }
++
++ #[test]
++ fn test_sanitize_for_display_preserves_newlines() {
++ let input = "line one\nline two";
++ assert_eq!(sanitize_for_display(input), input);
++ }
++
++ #[test]
++ fn test_sanitize_for_display_leaves_normal_text_untouched() {
++ let input = "some normal description, with punctuation! 42";
++ assert_eq!(sanitize_for_display(input), input);
++ }
++
++ #[test]
++ fn test_style_value_strips_control_chars_from_field() {
++ // style_value wraps the value in its own SGR escape codes, so this
++ // checks for the injected control bytes specifically, not for the
++ // absence of ESC entirely. The harmless leftover text ("]0;PWNED")
++ // is expected to remain once the ESC/BEL bytes around it are gone.
++ let colors = TextColors::new(&[], DynColors::Rgb(0xFF, 0xFF, 0xFF));
++ let info = InfoFieldImpl("1.0.0\u{1b}]0;PWNED\u{07}");
++ let styled = info.style_value(&colors).unwrap();
++ assert!(!styled.contains('\u{07}'));
++ assert!(styled.contains("1.0.0"));
++ assert_eq!(styled.matches('\u{FFFD}').count(), 2);
++ }
+ }
+
+From f6823dbfc62172befb0bf83d3e15473510b8c9b8 Mon Sep 17 00:00:00 2001
+From: o2sh <hjajiossama@gmail.com>
+Date: Mon, 28 Sep 2026 13:06:47 +0000
+Subject: [PATCH 3/4] fix: sanitize info field values per line
+
+Sanitize each line after splitting so CRLF text doesn't gain a trailing
+U+FFFD, and drop the now-unneeded `\n` exception. Rename
+`sanitize_for_display` to `sanitize`, trim comments, and replace redundant
+tests with coverage for CRLF, C1 CSI (U+009B) and lone `\r`.
+
+Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
+---
+ src/info/utils/info_field.rs | 60 +++++++++++++++++++-----------------
+ 1 file changed, 31 insertions(+), 29 deletions(-)
+
+diff --git a/src/info/utils/info_field.rs b/src/info/utils/info_field.rs
+index 51586ef8f..b4cea3d76 100644
+--- a/src/info/utils/info_field.rs
++++ b/src/info/utils/info_field.rs
+@@ -2,15 +2,11 @@ use crate::{info::utils::get_style, ui::text_colors::TextColors};
+ use owo_colors::OwoColorize;
+ use std::fmt;
+
+-/// Replaces control characters (which can include terminal escape sequences)
+-/// with the Unicode replacement character, since some field values (a
+-/// project manifest's version, name, description, or license, for example)
+-/// come from data with no character restrictions and shouldn't be trusted
+-/// to display as-is. `\n` is preserved since some fields intentionally span
+-/// multiple lines.
+-fn sanitize_for_display(s: &str) -> String {
++/// Replaces control characters so untrusted repository data can't inject
++/// terminal escape sequences.
++fn sanitize(s: &str) -> String {
+ s.chars()
+- .map(|c| if c != '\n' && c.is_control() { '\u{FFFD}' } else { c })
++ .map(|c| if c.is_control() { '\u{FFFD}' } else { c })
+ .collect()
+ }
+
+@@ -58,9 +54,9 @@ pub trait InfoField {
+ return None;
+ }
+ let style = get_style(false, text_colors.info);
+- let styled_lines: Vec<String> = sanitize_for_display(&self.value())
++ let styled_lines: Vec<String> = value
+ .lines()
+- .map(|line| format!("{}", line.style(style)))
++ .map(|line| format!("{}", sanitize(line).style(style)))
+ .collect();
+ Some(styled_lines.join("\n"))
+ }
+@@ -133,33 +129,23 @@ mod test {
+ }
+
+ #[test]
+- fn test_sanitize_for_display_strips_control_chars() {
+- // ESC ] 0 ; PWNED BEL, an OSC title-set sequence
+- let input = "1.0.0\u{1b}]0;PWNED\u{07}";
+- let sanitized = sanitize_for_display(input);
+- assert_eq!(sanitized, "1.0.0\u{FFFD}]0;PWNED\u{FFFD}");
+- assert!(!sanitized.contains('\u{1b}'));
+- assert!(!sanitized.contains('\u{07}'));
++ fn test_sanitize_strips_control_chars() {
++ // OSC set-title sequence
++ assert_eq!(
++ sanitize("1.0.0\u{1b}]0;PWNED\u{07}"),
++ "1.0.0\u{FFFD}]0;PWNED\u{FFFD}"
++ );
+ }
+
+ #[test]
+- fn test_sanitize_for_display_preserves_newlines() {
+- let input = "line one\nline two";
+- assert_eq!(sanitize_for_display(input), input);
+- }
+-
+- #[test]
+- fn test_sanitize_for_display_leaves_normal_text_untouched() {
++ fn test_sanitize_leaves_normal_text_untouched() {
+ let input = "some normal description, with punctuation! 42";
+- assert_eq!(sanitize_for_display(input), input);
++ assert_eq!(sanitize(input), input);
+ }
+
+ #[test]
+ fn test_style_value_strips_control_chars_from_field() {
+- // style_value wraps the value in its own SGR escape codes, so this
+- // checks for the injected control bytes specifically, not for the
+- // absence of ESC entirely. The harmless leftover text ("]0;PWNED")
+- // is expected to remain once the ESC/BEL bytes around it are gone.
++ // Output still contains ESC from our own color codes.
+ let colors = TextColors::new(&[], DynColors::Rgb(0xFF, 0xFF, 0xFF));
+ let info = InfoFieldImpl("1.0.0\u{1b}]0;PWNED\u{07}");
+ let styled = info.style_value(&colors).unwrap();
+@@ -167,4 +153,20 @@ mod test {
+ assert!(styled.contains("1.0.0"));
+ assert_eq!(styled.matches('\u{FFFD}').count(), 2);
+ }
++
++ #[test]
++ fn test_style_value_crlf_lines() {
++ let colors = TextColors::new(&[], DynColors::Rgb(0xFF, 0xFF, 0xFF));
++ let styled = InfoFieldImpl("line one\r\nline two")
++ .style_value(&colors)
++ .unwrap();
++ assert_eq!(styled.lines().count(), 2);
++ assert!(!styled.contains('\u{FFFD}'), "{styled:?}");
++ }
++
++ #[test]
++ fn test_sanitize_strips_c1_and_cr() {
++ assert_eq!(sanitize("1.0\u{9b}2J"), "1.0\u{FFFD}2J");
++ assert_eq!(sanitize("evil\rOK"), "evil\u{FFFD}OK");
++ }
+ }
+
+From c42f977d543a02993ee048620c359bf1cf7d08ab Mon Sep 17 00:00:00 2001
+From: o2sh <hjajiossama@gmail.com>
+Date: Mon, 28 Sep 2026 13:46:35 +0000
+Subject: [PATCH 4/4] refactor: simplify sanitize with str::replace
+
+Refs: CVE-2026-100866
+
+Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
+---
+ src/info/utils/info_field.rs | 4 +---
+ 1 file changed, 1 insertion(+), 3 deletions(-)
+
+diff --git a/src/info/utils/info_field.rs b/src/info/utils/info_field.rs
+index b4cea3d76..843ecfa64 100644
+--- a/src/info/utils/info_field.rs
++++ b/src/info/utils/info_field.rs
+@@ -5,9 +5,7 @@ use std::fmt;
+ /// Replaces control characters so untrusted repository data can't inject
+ /// terminal escape sequences.
+ fn sanitize(s: &str) -> String {
+- s.chars()
+- .map(|c| if c.is_control() { '\u{FFFD}' } else { c })
+- .collect()
++ s.replace(char::is_control, "\u{FFFD}")
+ }
+
+ #[typetag::serialize]
diff --git a/rust-onefetch.spec b/rust-onefetch.spec
index 6c988e1..7f54951 100644
--- a/rust-onefetch.spec
+++ b/rust-onefetch.spec
@@ -29,6 +29,12 @@ Patch: onefetch-fix-metadata-auto.diff
# reasonably citing upstream discouragement in
# https://github.com/Byron/gitoxide/discussions/900.
Patch: onefetch-fix-metadata.diff
+# * fix: strip control characters from info field values:
+# https://github.com/o2sh/onefetch/pull/1829
+# * Fixes: Info field values aren't stripped of terminal escape sequences:
+# https://github.com/o2sh/onefetch/issues/1828, CVE-2026-100866, RHBZ#2542292,
+# RHBZ#2542294
+Patch11: https://github.com/o2sh/onefetch/pull/1829.patch
BuildRequires: cargo-rpm-macros >= 26
BuildRequires: help2man
diff --git a/rust2rpm.toml b/rust2rpm.toml
index 22a0841..1f32072 100644
--- a/rust2rpm.toml
+++ b/rust2rpm.toml
@@ -36,6 +36,21 @@ extra-files = [
# library. This could be revisited if the situation changes.
cargo-install-lib = false
+[[package.extra-patches]]
+number = 11
+file = "https://github.com/o2sh/onefetch/pull/1829.patch"
+comments = [
+ """\
+fix: strip control characters from info field values: \
+https://github.com/o2sh/onefetch/pull/1829\
+""",
+ """\
+Fixes: Info field values aren't stripped of terminal escape sequences: \
+https://github.com/o2sh/onefetch/issues/1828, CVE-2026-100866, \
+RHBZ#2542292, RHBZ#2542294\
+""",
+]
+
[requires]
build = [
"help2man",
reply other threads:[~2026-10-08 11:28 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=179145890474.1.13820636150249551769.rpms-rust-onefetch-ec7de03495e1@fedoraproject.org \
--to=code@musicinmybrain.net \
--cc=git-commits@fedoraproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox