Skip to content

Commit 15ffdc3

Browse files
authored
[Medium] Patch gh for CVE-2025-48938 (microsoft#14015)
Signed-off-by: Sreenivasulu Malavathula <[email protected]>
1 parent c627b4b commit 15ffdc3

File tree

2 files changed

+103
-1
lines changed

2 files changed

+103
-1
lines changed

SPECS/gh/CVE-2025-48938.patch

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
From f30373d5ac9c1af048f352ce32eaddc7c83a9156 Mon Sep 17 00:00:00 2001
2+
From: Sreenivasulu Malavathula <[email protected]>
3+
Date: Mon, 16 Jun 2025 16:28:52 -0500
4+
Subject: [PATCH] Address CVE-2025-48938
5+
Upstream Patch Reference: https://github.com/cli/go-gh/commit/a08820a.diff
6+
7+
---
8+
.../cli/go-gh/v2/pkg/browser/browser.go | 59 +++++++++++++++++++
9+
1 file changed, 59 insertions(+)
10+
11+
diff --git a/vendor/github.com/cli/go-gh/v2/pkg/browser/browser.go b/vendor/github.com/cli/go-gh/v2/pkg/browser/browser.go
12+
index 4d56710..d17951a 100644
13+
--- a/vendor/github.com/cli/go-gh/v2/pkg/browser/browser.go
14+
+++ b/vendor/github.com/cli/go-gh/v2/pkg/browser/browser.go
15+
@@ -2,7 +2,9 @@
16+
package browser
17+
18+
import (
19+
+ "fmt"
20+
"io"
21+
+ "net/url"
22+
"os"
23+
"os/exec"
24+
25+
@@ -45,9 +47,20 @@ func (b *Browser) Browse(url string) error {
26+
}
27+
28+
func (b *Browser) browse(url string, env []string) error {
29+
+ // Ensure the URL is supported including the scheme,
30+
+ // overwrite `url` for use within the function.
31+
+ urlParsed, err := isPossibleProtocol(url)
32+
+ if err != nil {
33+
+ return err
34+
+ }
35+
+
36+
+ url = urlParsed.String()
37+
+
38+
+ // Use default `gh` browsing module for opening URL if not customized.
39+
if b.launcher == "" {
40+
return cliBrowser.OpenURL(url)
41+
}
42+
+
43+
launcherArgs, err := shlex.Split(b.launcher)
44+
if err != nil {
45+
return err
46+
@@ -78,3 +91,49 @@ func resolveLauncher() string {
47+
}
48+
return os.Getenv("BROWSER")
49+
}
50+
+
51+
+func isSupportedScheme(scheme string) bool {
52+
+ switch scheme {
53+
+ case "http", "https", "vscode", "vscode-insiders":
54+
+ return true
55+
+ default:
56+
+ return false
57+
+ }
58+
+}
59+
+
60+
+func isPossibleProtocol(u string) (*url.URL, error) {
61+
+ // Parse URL for known supported schemes before handling unknown cases.
62+
+ urlParsed, err := url.Parse(u)
63+
+ if err != nil {
64+
+ return nil, fmt.Errorf("opening unparsable URL is unsupported: %s", u)
65+
+ }
66+
+
67+
+ if isSupportedScheme(urlParsed.Scheme) {
68+
+ return urlParsed, nil
69+
+ }
70+
+
71+
+ // Disallow any unrecognized URL schemes if explicitly present.
72+
+ if urlParsed.Scheme != "" {
73+
+ return nil, fmt.Errorf("opening unsupport URL scheme: %s", u)
74+
+ }
75+
+
76+
+ // Disallow URLs that match existing files or directories on the filesystem
77+
+ // as these could be executables or executed by the launcher browser due to
78+
+ // the file extension and/or associated application.
79+
+ //
80+
+ // Symlinks should not be resolved in order to avoid broken links or other
81+
+ // vulnerabilities trying to resolve them.
82+
+ if fileInfo, _ := os.Lstat(u); fileInfo != nil {
83+
+ return nil, fmt.Errorf("opening files or directories is unsupported: %s", u)
84+
+ }
85+
+
86+
+ // Disallow URLs that match executables found in the user path.
87+
+ exec, _ := safeexec.LookPath(u)
88+
+ if exec != "" {
89+
+ return nil, fmt.Errorf("opening executables is unsupported: %s", u)
90+
+ }
91+
+
92+
+ // Otherwise, assume HTTP URL using `https` to ensure secure browsing.
93+
+ urlParsed.Scheme = "https"
94+
+ return urlParsed, nil
95+
+}
96+
--
97+
2.45.2
98+

SPECS/gh/gh.spec

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Summary: GitHub official command line tool
22
Name: gh
33
Version: 2.62.0
4-
Release: 8%{?dist}
4+
Release: 9%{?dist}
55
License: MIT
66
Vendor: Microsoft Corporation
77
Distribution: Azure Linux
@@ -22,6 +22,7 @@ Patch6: CVE-2025-25204.patch
2222
Patch7: CVE-2025-27144.patch
2323
Patch8: CVE-2025-22869.patch
2424
Patch9: CVE-2025-22872.patch
25+
Patch10: CVE-2025-48938.patch
2526

2627
BuildRequires: golang < 1.23
2728
BuildRequires: git
@@ -64,6 +65,9 @@ make test
6465
%{_datadir}/zsh/site-functions/_gh
6566

6667
%changelog
68+
* Mon Jun 16 2025 Sreeniavsulu Malavathula <[email protected]> - 2.62.0-9
69+
- Patch CVE-2025-48938
70+
6771
* Tue Apr 22 2025 Jyoti Kanase <[email protected]> - 2.62.0-8
6872
- Patch CVE-2025-22872
6973

0 commit comments

Comments
 (0)