new file mode 100644
@@ -0,0 +1,125 @@
+From 8ac799963bb9cb1af1518040a12f184e82625285 Mon Sep 17 00:00:00 2001
+From: Karthik Nayak <karthik.188@gmail.com>
+Date: Tue, 17 Mar 2026 23:05:55 +0100
+Subject: [PATCH] fast-import: add safeguard around rewrite-submodules features
+
+In 68061e3470 (fast-import: disallow "feature export-marks" by default,
+2019-08-29), we disallowed the `export-marks` feature by default. This
+was followed by a52ed76142 (fast-import: disallow "feature import-marks"
+by default, 2019-08-29) where we also disabled `import-marks` and
+`import-marks-if-exists`.
+
+This was because these features provided arbitrary read/write access to
+the filesystem. Since then, 1bdca81641 (fast-import: add options for
+rewriting submodules, 2020-02-22) added support for two new features:
+
+ - rewrite-submodules-to
+ - rewrite-submodules-from
+
+Both of which take in a <file> argument and can read arbitrary files.
+When provided with an unsupported file, they error out with `fatal:
+corrupt mark line: <file-content>`. This allows attackers to read from
+the filesystem.
+
+In accordance with the earlier patches, also safeguard the new features
+behind the '--allow-unsafe-features' option. This is a backward
+incompatible change. But as mentioned in 68061e3470 (fast-import:
+disallow "feature export-marks" by default, 2019-08-29), this option is
+provided to import/export based remote helpers so the impact should be
+minimal.
+
+CVE: CVE-2026-114466
+Upstream-Status: Backport [https://github.com/git/git/commit/2b50a97225c9fa937c4160f7da5132e880fa500f]
+
+Reported-by: pwn2addr <p2addr@gmail.com>
+Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
+Signed-off-by: Ashishkumar Parmar <asparmar@cisco.com>
+---
+ Documentation/git-fast-import.adoc | 11 +++++++++--
+ builtin/fast-import.c | 2 ++
+ t/t9300-fast-import.sh | 29 +++++++++++++++++++++++++++++
+ 3 files changed, 40 insertions(+), 2 deletions(-)
+
+diff --git a/Documentation/git-fast-import.adoc b/Documentation/git-fast-import.adoc
+index 479c4081..bd65d1bd 100644
+--- a/Documentation/git-fast-import.adoc
++++ b/Documentation/git-fast-import.adoc
+@@ -58,8 +58,15 @@ OPTIONS
+ allowing fast-import to access the filesystem outside of the
+ repository). These options are disabled by default, but can be
+ allowed by providing this option on the command line. This
+- currently impacts only the `export-marks`, `import-marks`, and
+- `import-marks-if-exists` feature commands.
++ currently impacts the following feature commands:
+++
++--
++* `export-marks`
++* `import-marks-if-exists`
++* `import-marks`
++* `rewrite-submodules-from`
++* `rewrite-submodules-to`
++--
+ +
+ Only enable this option if you trust the program generating the
+ fast-import stream! This option is enabled automatically for
+diff --git a/builtin/fast-import.c b/builtin/fast-import.c
+index b8a7757c..fa3f868b 100644
+--- a/builtin/fast-import.c
++++ b/builtin/fast-import.c
+@@ -3693,8 +3693,10 @@ static int parse_one_feature(const char *feature, int from_stream)
+ } else if (!strcmp(feature, "alias")) {
+ ; /* Don't die - this feature is supported */
+ } else if (skip_prefix(feature, "rewrite-submodules-to=", &arg)) {
++ check_unsafe_feature("rewrite-submodules-to", from_stream);
+ option_rewrite_submodules(arg, &sub_marks_to);
+ } else if (skip_prefix(feature, "rewrite-submodules-from=", &arg)) {
++ check_unsafe_feature("rewrite-submodules-from", from_stream);
+ option_rewrite_submodules(arg, &sub_marks_from);
+ } else if (!strcmp(feature, "get-mark")) {
+ ; /* Don't die - this feature is supported */
+diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
+index 5685cce6..6154b23d 100755
+--- a/t/t9300-fast-import.sh
++++ b/t/t9300-fast-import.sh
+@@ -3923,7 +3923,20 @@ test_expect_success 'Y: setup' '
+ EOF
+ '
+
++test_expect_success 'Y: rewrite-submodules-to feature forbidden by default' '
++ echo "feature rewrite-submodules-to=sub:sub2-marks" >input &&
++ test_must_fail git fast-import <input 2>err &&
++ test_grep "feature ${SQ}rewrite-submodules-to${SQ} forbidden in input without --allow-unsafe-features" err
++'
++
++test_expect_success 'Y: rewrite-submodules-from feature forbidden by default' '
++ echo "feature rewrite-submodules-from=sub:../Y-marks" >input &&
++ test_must_fail git fast-import <input 2>err &&
++ test_grep "feature ${SQ}rewrite-submodules-from${SQ} forbidden in input without --allow-unsafe-features" err
++'
++
+ test_expect_success 'Y: rewrite submodules' '
++ test_when_finished "rm -rf main1" &&
+ git init main1 &&
+ (
+ cd main1 &&
+@@ -3935,4 +3948,20 @@ test_expect_success 'Y: rewrite submodules' '
+ )
+ '
+
++test_expect_success 'Y: rewrite submodules via stdin' '
++ test_when_finished "rm -rf main1" &&
++ git init main1 &&
++ (
++ cd main1 &&
++ git init sub2 &&
++ git -C sub2 fast-import --export-marks=../sub2-marks <../Y-sub-input &&
++ {
++ echo "feature rewrite-submodules-to=sub:sub2-marks" &&
++ echo "feature rewrite-submodules-from=sub:../Y-marks" &&
++ cat ../Y-main-input
++ } | git fast-import --allow-unsafe-features &&
++ test "$(git rev-parse main)" = "$(test_oid Ymain)"
++ )
++'
++
+ test_done
new file mode 100644
@@ -0,0 +1,146 @@
+From 58cf54caf290303e4fd98a15506327aeb7be61a4 Mon Sep 17 00:00:00 2001
+From: Karthik Nayak <karthik.188@gmail.com>
+Date: Tue, 17 Mar 2026 23:05:56 +0100
+Subject: [PATCH] fast-import: add safeguard around 'export-pack-edges'
+
+Similar to the previous commit, also add a safeguard around the
+'export-pack-edges'. The 'export-pack-edges' option takes in a file as
+an argument. This can be exploited by an attacker to open a file in
+append mode and write pack-edge records to it.
+
+The file is created even if no pack-edge records are ultimately
+written (i.e., even without commits), since `xfopen()` creates the file
+on open. With a commit and `transfer.unpackLimit=0` (to prevent pack
+loosening), attacker-controlled data can also be written to the file.
+
+Add the necessary tests, this includes combining two of the previous
+tests which were split into {creation, validation} to ensure a clean
+setup for the new tests.
+
+CVE: CVE-2026-114466
+Upstream-Status: Backport [https://github.com/git/git/commit/19bcf62ed0597b7487c3f4ed2de3c9d97b921de8]
+
+Reported-by: pwn2addr <p2addr@gmail.com>
+Signed-off-by: Karthik Nayak <karthik.188@gmail.com>
+Signed-off-by: Ashishkumar Parmar <asparmar@cisco.com>
+---
+ Documentation/git-fast-import.adoc | 5 +++++
+ builtin/fast-import.c | 14 +++++++++++---
+ t/t9300-fast-import.sh | 31 +++++++++++++++++++++++++++---
+ 3 files changed, 44 insertions(+), 6 deletions(-)
+
+diff --git a/Documentation/git-fast-import.adoc b/Documentation/git-fast-import.adoc
+index bd65d1bd..8c525d12 100644
+--- a/Documentation/git-fast-import.adoc
++++ b/Documentation/git-fast-import.adoc
+@@ -67,6 +67,11 @@ OPTIONS
+ * `rewrite-submodules-from`
+ * `rewrite-submodules-to`
+ --
++And the following options:
+++
++--
++* `export-pack-edges`
++--
+ +
+ Only enable this option if you trust the program generating the
+ fast-import stream! This option is enabled automatically for
+diff --git a/builtin/fast-import.c b/builtin/fast-import.c
+index fa3f868b..0ec51eb6 100644
+--- a/builtin/fast-import.c
++++ b/builtin/fast-import.c
+@@ -3623,7 +3623,14 @@ static void option_rewrite_submodules(const char *arg, struct string_list *list)
+ free(s);
+ }
+
+-static int parse_one_option(const char *option)
++static void check_unsafe_option(const char *option, int from_stream)
++{
++ if (from_stream && !allow_unsafe_features)
++ die(_("option '%s' forbidden in input without --allow-unsafe-features"),
++ option);
++}
++
++static int parse_one_option(const char *option, int from_stream)
+ {
+ if (skip_prefix(option, "max-pack-size=", &option)) {
+ unsigned long v;
+@@ -3647,6 +3654,7 @@ static int parse_one_option(const char *option)
+ } else if (skip_prefix(option, "active-branches=", &option)) {
+ option_active_branches(option);
+ } else if (skip_prefix(option, "export-pack-edges=", &option)) {
++ check_unsafe_option("export-pack-edges", from_stream);
+ option_export_pack_edges(option);
+ } else if (skip_prefix(option, "signed-commits=", &option)) {
+ if (parse_sign_mode(option, &signed_commit_mode))
+@@ -3735,7 +3743,7 @@ static void parse_option(const char *option)
+ if (seen_data_command)
+ die(_("got option command '%s' after data command"), option);
+
+- if (parse_one_option(option))
++ if (parse_one_option(option, 1))
+ return;
+
+ die(_("this version of fast-import does not support option: %s"), option);
+@@ -3784,7 +3792,7 @@ static void parse_argv(void)
+ if (!skip_prefix(a, "--", &a))
+ die(_("unknown option %s"), a);
+
+- if (parse_one_option(a))
++ if (parse_one_option(a, 0))
+ continue;
+
+ if (parse_one_feature(a, 0))
+diff --git a/t/t9300-fast-import.sh b/t/t9300-fast-import.sh
+index 6154b23d..fdeb23ba 100755
+--- a/t/t9300-fast-import.sh
++++ b/t/t9300-fast-import.sh
+@@ -912,7 +912,14 @@ test_expect_success 'H: verify file' '
+ ### series I
+ ###
+
++test_expect_success 'I: export-pack-edges option forbidden by default' '
++ echo "option git export-pack-edges=edges.list" >input &&
++ test_must_fail git fast-import <input 2>err &&
++ test_grep "option ${SQ}export-pack-edges${SQ} forbidden in input without --allow-unsafe-features" err
++'
++
+ test_expect_success 'I: export-pack-edges' '
++ test_when_finished "rm edges.list" &&
+ cat >input <<-INPUT_END &&
+ commit refs/heads/export-boundary
+ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
+@@ -923,12 +930,30 @@ test_expect_success 'I: export-pack-edges' '
+ from refs/heads/branch
+
+ INPUT_END
+- git fast-import --export-pack-edges=edges.list <input
++ git fast-import --export-pack-edges=edges.list <input &&
++ cat >expect <<-EOF &&
++ .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary)
++ EOF
++ sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
++ test_cmp expect actual
+ '
+
+-test_expect_success 'I: verify edge list' '
++test_expect_success 'I: export-pack-edges via stdin' '
++ test_when_finished "rm edges.list" &&
++ cat >input <<-INPUT_END &&
++ option git export-pack-edges=edges.list
++ commit refs/heads/export-boundary-2
++ committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
++ data <<COMMIT
++ one more similar commit
++ COMMIT
++
++ from refs/heads/branch
++
++ INPUT_END
++ git fast-import --allow-unsafe-features <input &&
+ cat >expect <<-EOF &&
+- .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary)
++ .git/objects/pack/pack-.pack: $(git rev-parse --verify export-boundary-2)
+ EOF
+ sed -e s/pack-.*pack/pack-.pack/ edges.list >actual &&
+ test_cmp expect actual
@@ -15,6 +15,8 @@ SRC_URI = "${KERNELORG_MIRROR}/software/scm/git/git-${PV}.tar.gz;name=tarball \
file://CVE-2026-113408_p1.patch \
file://CVE-2026-113408_p2.patch \
file://CVE-2026-113408_p3.patch \
+ file://CVE-2026-114466_p1.patch \
+ file://CVE-2026-114466_p2.patch \
"
SRC_URI:append:class-nativesdk = " \