public inbox for git-commits@fedoraproject.org
help / color / mirror / Atom feed
From: Peter Lemenkov <lemenkov@gmail.com>
To: git-commits@fedoraproject.org
Subject: [rpms/vyper] rawhide: Backport fixes for CVE-2026-114114, CVE-2026-114118 and GHSA-cw3h-xwxq-8cx2
Date: Tue, 03 Nov 2026 06:44:28 GMT	[thread overview]
Message-ID: <179368826836.1.3973312442517479262.rpms-vyper-4465058cf6ab@fedoraproject.org> (raw)

            A new commit has been pushed.

            Repo   : rpms/vyper
            Branch : rawhide
            Commit : 4465058cf6abfc63f406443b6569cd235f1e2efd
            Author : Peter Lemenkov <lemenkov@gmail.com>
            Date   : 2026-11-03T07:34:49+01:00
            Stats  : +865/-5 in 8 file(s)
            URL    : https://src.fedoraproject.org/rpms/vyper/c/4465058cf6abfc63f406443b6569cd235f1e2efd?branch=rawhide

            Log:
            Backport fixes for CVE-2026-114114, CVE-2026-114118 and GHSA-cw3h-xwxq-8cx2

- CVE-2026-114114, GHSA-wvx7-39qj-2g9v: compute AST source spans from
  CPython-style line splitting and UTF-8 byte offsets, so multi-byte
  characters, line-separator characters and a leading BOM can no longer
  silently change literal values (upstream PR #5294, unmerged, plus a
  BOM fix)
- CVE-2026-114118: check create_from_blueprint's code_offset against
  extcodesize with an unsigned comparison before subtracting, so a
  wrapping offset can no longer deploy an empty contract (legacy
  counterpart of upstream venom fix d3c150e4a)
- GHSA-cw3h-xwxq-8cx2: widen ternary arms to the result type's memory
  layout, so nested arrays of different bounds are no longer misread
  (upstream 1fb7dfe2e, #5236)

Resolves: rhbz#2558184, rhbz#2558193

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>

---
diff --git a/vyper-0001-Use-Cryptodomex.patch b/vyper-0001-Use-Cryptodomex.patch
index 2f9d213..6ce1e62 100644
--- a/vyper-0001-Use-Cryptodomex.patch
+++ b/vyper-0001-Use-Cryptodomex.patch
@@ -1,3 +1,4 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Peter Lemenkov <lemenkov@gmail.com>
 Date: Tue, 1 Nov 2022 20:45:19 +0100
 Subject: [PATCH] Use Cryptodomex
@@ -5,7 +6,7 @@ Subject: [PATCH] Use Cryptodomex
 Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
 
 diff --git a/setup.py b/setup.py
-index a3cb94c5..4daf01be 100644
+index a3cb94c51..4daf01be6 100644
 --- a/setup.py
 +++ b/setup.py
 @@ -92,7 +92,7 @@ setup(
@@ -18,7 +19,7 @@ index a3cb94c5..4daf01be 100644
          "lark>=1.0.0,<2",
          "wheel",
 diff --git a/vyper/utils.py b/vyper/utils.py
-index 9b1084ab..2896a1e0 100644
+index 9b1084ab8..2896a1e0f 100644
 --- a/vyper/utils.py
 +++ b/vyper/utils.py
 @@ -11,7 +11,7 @@ import traceback

diff --git a/vyper-0002-Ease-version-requirements.patch b/vyper-0002-Ease-version-requirements.patch
index f7306bf..667a4c7 100644
--- a/vyper-0002-Ease-version-requirements.patch
+++ b/vyper-0002-Ease-version-requirements.patch
@@ -1,3 +1,4 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Peter Lemenkov <lemenkov@gmail.com>
 Date: Mon, 10 Apr 2023 15:40:39 +0200
 Subject: [PATCH] Ease version requirements
@@ -5,7 +6,7 @@ Subject: [PATCH] Ease version requirements
 Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
 
 diff --git a/setup.py b/setup.py
-index 4daf01be..e6613671 100644
+index 4daf01be6..e66136714 100644
 --- a/setup.py
 +++ b/setup.py
 @@ -98,7 +98,7 @@ setup(

diff --git a/vyper-0003-Remove-unnecessary-shebang.patch b/vyper-0003-Remove-unnecessary-shebang.patch
index a6b7708..4131256 100644
--- a/vyper-0003-Remove-unnecessary-shebang.patch
+++ b/vyper-0003-Remove-unnecessary-shebang.patch
@@ -1,3 +1,4 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
 From: Peter Lemenkov <lemenkov@gmail.com>
 Date: Thu, 8 Aug 2024 12:56:13 +0200
 Subject: [PATCH] Remove unnecessary shebang
@@ -5,7 +6,7 @@ Subject: [PATCH] Remove unnecessary shebang
 Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
 
 diff --git a/vyper/__main__.py b/vyper/__main__.py
-index c5bda47b..a29d50bf 100644
+index c5bda47be..a29d50bf3 100644
 --- a/vyper/__main__.py
 +++ b/vyper/__main__.py
 @@ -1,4 +1,3 @@

diff --git a/vyper-0004-Relax-lark-dependency.patch b/vyper-0004-Relax-lark-dependency.patch
new file mode 100644
index 0000000..816333a
--- /dev/null
+++ b/vyper-0004-Relax-lark-dependency.patch
@@ -0,0 +1,20 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Thu, 25 Jul 2024 23:18:23 +0200
+Subject: [PATCH] Relax lark dependency
+
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/setup.py b/setup.py
+index e66136714..63922ce88 100644
+--- a/setup.py
++++ b/setup.py
+@@ -15,7 +15,7 @@ extras_require = {
+         "pytest-split>=0.7.0,<1.0",
+         "eth_abi>=5.0.0,<6.0.0",
+         "py-evm>=0.12.1b1",
+-        "lark==1.1.9",
++        "lark>=1.1.9",
+         "hypothesis[lark]>=6.0,<7.0",
+         "eth-stdlib==0.2.7",
+         "eth-account==0.12.2",

diff --git a/vyper-0005-fix-codegen-widen-ternary-arms-to-the-result-type-la.patch b/vyper-0005-fix-codegen-widen-ternary-arms-to-the-result-type-la.patch
new file mode 100644
index 0000000..69047c0
--- /dev/null
+++ b/vyper-0005-fix-codegen-widen-ternary-arms-to-the-result-type-la.patch
@@ -0,0 +1,428 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Harry Kalogirou <harry@kalogirou.net>
+Date: Fri, 4 Sep 2026 10:41:12 +0300
+Subject: [PATCH] fix[codegen]: widen ternary arms to the result type layout
+ (#5236)
+
+both codegen pipelines lower a ternary by lowering each arm to a pointer
+into the arm's own memory layout and typing the result with the expected
+(widened) type that semantic analysis stamps on the node. semantic
+analysis only stamps the root node; the arms keep their exact types.
+when an arm is narrower than the result -- e.g. `DynArray[Bytes[10], 5]`
+for a `DynArray[Bytes[512], 5]` result -- every consumer walks the
+narrow data with the wide element stride and reads garbage. the same
+happens for nested dynarray capacity, static arrays of dynarrays, string
+elements and widened tuple members reached through locals or internal
+call results. the legacy pipeline (`parse_IfExp`) and the venom pipeline
+(`lower_IfExp`) have the same defect.
+
+convert each arm to the result layout inside its own branch, before the
+join, so the result pointer genuinely has the result type's layout.
+legacy does this with `make_setter` into an internal variable of the
+result type; venom with its typed memory store. both already widen
+element-wise. the gate is a shared structural layout check
+(`same_memory_layout` in codegen/core.py) comparing element and member
+layout of dynarrays, static arrays and tuples, rather than type
+equality: same-type arms, bytestring arms with different bounds,
+capacity-only widening and unbounded result types stay copy-free and
+produce identical IR, and the check works for tuples even though
+`TupleT.__eq__` always returns True.
+
+(cherry picked from commit 1fb7dfe2ebf9e5adc4b05a55cdf8ce2142fbf9c3)
+
+[Backport to 0.4.3: only the legacy codegen half (vyper/codegen/core.py, vyper/codegen/expr.py) is needed, since the 0.4.3 venom pipeline is generated from legacy IR and vyper/codegen_venom does not exist. The two tests using unbounded (INF) sequence types are dropped; 0.4.3 does not have them. Fixes GHSA-cw3h-xwxq-8cx2.]
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/tests/functional/codegen/features/test_ternary_widening.py b/tests/functional/codegen/features/test_ternary_widening.py
+new file mode 100644
+index 000000000..04012d485
+--- /dev/null
++++ b/tests/functional/codegen/features/test_ternary_widening.py
+@@ -0,0 +1,285 @@
++import pytest
++
++from vyper.compiler import compile_code
++
++SHORT = [b"a", b"0123456789", b""]
++LONG = [b"x" * 512, b"", b"0123456789" * 20]
++
++
++def test_dynarray_bytes_widening(get_contract):
++    code = """
++@external
++def via_local(
++    c: bool, a: DynArray[Bytes[10], 5], b: DynArray[Bytes[512], 5]
++) -> DynArray[Bytes[512], 5]:
++    ys: DynArray[Bytes[512], 5] = a if c else b
++    return ys
++
++@external
++def via_return(
++    c: bool, a: DynArray[Bytes[10], 5], b: DynArray[Bytes[512], 5]
++) -> DynArray[Bytes[512], 5]:
++    return a if c else b
++
++@external
++def via_local_flipped(
++    c: bool, a: DynArray[Bytes[512], 5], b: DynArray[Bytes[10], 5]
++) -> DynArray[Bytes[512], 5]:
++    ys: DynArray[Bytes[512], 5] = a if c else b
++    return ys
++
++@external
++def via_return_flipped(
++    c: bool, a: DynArray[Bytes[512], 5], b: DynArray[Bytes[10], 5]
++) -> DynArray[Bytes[512], 5]:
++    return a if c else b
++    """
++    c = get_contract(code)
++    assert c.via_local(True, SHORT, LONG) == SHORT
++    assert c.via_local(False, SHORT, LONG) == LONG
++    assert c.via_return(True, SHORT, LONG) == SHORT
++    assert c.via_return(False, SHORT, LONG) == LONG
++    assert c.via_local_flipped(True, LONG, SHORT) == LONG
++    assert c.via_local_flipped(False, LONG, SHORT) == SHORT
++    assert c.via_return_flipped(True, LONG, SHORT) == LONG
++    assert c.via_return_flipped(False, LONG, SHORT) == SHORT
++
++
++def test_dynarray_arms_of_different_widths(get_contract):
++    code = """
++@external
++def foo(
++    c: bool, a: DynArray[Bytes[10], 4], b: DynArray[Bytes[40], 4]
++) -> DynArray[Bytes[512], 4]:
++    return a if c else b
++
++@external
++def flipped(
++    c: bool, a: DynArray[Bytes[40], 4], b: DynArray[Bytes[10], 4]
++) -> DynArray[Bytes[512], 4]:
++    return a if c else b
++    """
++    a = [b"a", b"0123456789", b"", b"xyz"]
++    b = [b"q" * 40, b"", b"0123456789" * 4]
++    c = get_contract(code)
++    assert c.foo(True, a, b) == a
++    assert c.foo(False, a, b) == b
++    assert c.flipped(True, b, a) == b
++    assert c.flipped(False, b, a) == a
++
++
++def test_nested_dynarray_widening(get_contract):
++    code = """
++@external
++def foo(
++    c: bool, a: DynArray[DynArray[uint256, 2], 3], b: DynArray[DynArray[uint256, 4], 3]
++) -> DynArray[DynArray[uint256, 4], 3]:
++    return a if c else b
++
++@external
++def flipped(
++    c: bool, a: DynArray[DynArray[uint256, 4], 3], b: DynArray[DynArray[uint256, 2], 3]
++) -> DynArray[DynArray[uint256, 4], 3]:
++    return a if c else b
++    """
++    a = [[1, 2], [], [3]]
++    b = [[4, 5, 6, 7], [8]]
++    c = get_contract(code)
++    assert c.foo(True, a, b) == a
++    assert c.foo(False, a, b) == b
++    assert c.flipped(True, b, a) == b
++    assert c.flipped(False, b, a) == a
++
++
++def test_dynarray_string_widening(get_contract):
++    code = """
++@external
++def foo(
++    c: bool, a: DynArray[String[5], 3], b: DynArray[String[100], 3]
++) -> DynArray[String[100], 3]:
++    ys: DynArray[String[100], 3] = a if c else b
++    return ys
++
++@external
++def flipped(
++    c: bool, a: DynArray[String[100], 3], b: DynArray[String[5], 3]
++) -> DynArray[String[100], 3]:
++    ys: DynArray[String[100], 3] = a if c else b
++    return ys
++    """
++    a = ["hello", "", "hi"]
++    b = ["0123456789" * 10, "x"]
++    c = get_contract(code)
++    assert c.foo(True, a, b) == a
++    assert c.foo(False, a, b) == b
++    assert c.flipped(True, b, a) == b
++    assert c.flipped(False, b, a) == a
++
++
++def test_static_array_of_dynarray_widening(get_contract):
++    code = """
++@external
++def foo(
++    c: bool, a: DynArray[uint256, 2][2], b: DynArray[uint256, 4][2]
++) -> DynArray[uint256, 4][2]:
++    return a if c else b
++
++@external
++def flipped(
++    c: bool, a: DynArray[uint256, 4][2], b: DynArray[uint256, 2][2]
++) -> DynArray[uint256, 4][2]:
++    return a if c else b
++    """
++    a = [[1, 2], [3]]
++    b = [[4, 5, 6, 7], [8]]
++    c = get_contract(code)
++    assert c.foo(True, a, b) == a
++    assert c.foo(False, a, b) == b
++    assert c.flipped(True, b, a) == b
++    assert c.flipped(False, b, a) == a
++
++
++def _ternaries(ir_node, source):
++    if ir_node.value == "if" and ir_node.annotation == source:
++        yield ir_node
++    for arg in ir_node.args:
++        yield from _ternaries(arg, source)
++
++
++def test_same_type_ternary(get_contract, compiler_settings, experimental_codegen):
++    code = """
++@external
++def foo(
++    c: bool, a: DynArray[Bytes[512], 5], b: DynArray[Bytes[512], 5]
++) -> DynArray[Bytes[512], 5]:
++    ys: DynArray[Bytes[512], 5] = a if c else b
++    return ys
++
++@external
++def bar(c: bool, a: DynArray[uint256, 2], b: DynArray[uint256, 5]) -> DynArray[uint256, 5]:
++    return a if c else b
++    """
++    c = get_contract(code)
++    assert c.foo(True, SHORT, LONG) == SHORT
++    assert c.foo(False, SHORT, LONG) == LONG
++    assert c.bar(True, [1, 2], [3, 4, 5, 6, 7]) == [1, 2]
++    assert c.bar(False, [1, 2], [3, 4, 5, 6, 7]) == [3, 4, 5, 6, 7]
++
++    # the arms already have the element layout of the result, so neither
++    # arm is converted element by element
++    ir = compile_code(code, output_formats=["ir_runtime"], settings=compiler_settings)
++    ir = ir["ir_runtime"]
++    if experimental_codegen:
++        assert "typed_dyn_copy" not in str(ir)
++    else:
++        ternaries = list(_ternaries(ir, "a if c else b"))
++        assert len(ternaries) == 2
++        for ternary in ternaries:
++            _, body, orelse = ternary.args
++            # each arm is the variable itself, not a copy of it
++            assert body.is_literal
++            assert orelse.is_literal
++
++
++def test_bytestring_ternary(get_contract):
++    code = """
++@external
++def foo(c: bool, a: Bytes[10], b: Bytes[20]) -> Bytes[20]:
++    return a if c else b
++
++@external
++def bar(c: bool, a: String[3], b: String[64]) -> String[64]:
++    s: String[64] = a if c else b
++    return s
++
++@external
++def foo_flipped(c: bool, a: Bytes[20], b: Bytes[10]) -> Bytes[20]:
++    return a if c else b
++
++@external
++def bar_flipped(c: bool, a: String[64], b: String[3]) -> String[64]:
++    s: String[64] = a if c else b
++    return s
++    """
++    c = get_contract(code)
++    assert c.foo(True, b"0123456789", b"x" * 20) == b"0123456789"
++    assert c.foo(False, b"0123456789", b"x" * 20) == b"x" * 20
++    assert c.bar(True, "abc", "y" * 64) == "abc"
++    assert c.bar(False, "abc", "y" * 64) == "y" * 64
++    assert c.foo_flipped(True, b"x" * 20, b"0123456789") == b"x" * 20
++    assert c.foo_flipped(False, b"x" * 20, b"0123456789") == b"0123456789"
++    assert c.bar_flipped(True, "y" * 64, "abc") == "y" * 64
++    assert c.bar_flipped(False, "y" * 64, "abc") == "abc"
++
++
++def test_ternary_as_event_argument(get_contract, get_logs):
++    code = """
++event Picked:
++    xs: DynArray[Bytes[512], 5]
++
++@external
++def foo(c: bool, a: DynArray[Bytes[10], 5], b: DynArray[Bytes[512], 5]):
++    log Picked(xs=a if c else b)
++
++@external
++def flipped(c: bool, a: DynArray[Bytes[512], 5], b: DynArray[Bytes[10], 5]):
++    log Picked(xs=a if c else b)
++    """
++    c = get_contract(code)
++
++    c.foo(True, SHORT, LONG)
++    (log,) = get_logs(c, "Picked")
++    assert log.args.xs == SHORT
++
++    c.foo(False, SHORT, LONG)
++    (log,) = get_logs(c, "Picked")
++    assert log.args.xs == LONG
++
++    c.flipped(True, LONG, SHORT)
++    (log,) = get_logs(c, "Picked")
++    assert log.args.xs == LONG
++
++    c.flipped(False, LONG, SHORT)
++    (log,) = get_logs(c, "Picked")
++    assert log.args.xs == SHORT
++
++
++def test_tuple_ternary(get_contract):
++    code = """
++@internal
++def _short(a: Bytes[10]) -> (Bytes[10], uint256):
++    return a, 1
++
++@internal
++def _long(b: Bytes[40]) -> (Bytes[40], uint256):
++    return b, 2
++
++@external
++def from_calls(c: bool, a: Bytes[10], b: Bytes[40]) -> (Bytes[40], uint256):
++    return self._short(a) if c else self._long(b)
++
++@external
++def from_locals(c: bool, a: Bytes[10], b: Bytes[40]) -> (Bytes[40], uint256):
++    x: (Bytes[10], uint256) = (a, 1)
++    y: (Bytes[40], uint256) = (b, 2)
++    return x if c else y
++
++@external
++def from_calls_flipped(c: bool, a: Bytes[40], b: Bytes[10]) -> (Bytes[40], uint256):
++    return self._long(a) if c else self._short(b)
++
++@external
++def from_locals_flipped(c: bool, a: Bytes[40], b: Bytes[10]) -> (Bytes[40], uint256):
++    x: (Bytes[40], uint256) = (a, 2)
++    y: (Bytes[10], uint256) = (b, 1)
++    return x if c else y
++    """
++    c = get_contract(code)
++    assert c.from_calls(True, b"abc", b"x" * 40) == (b"abc", 1)
++    assert c.from_calls(False, b"abc", b"x" * 40) == (b"x" * 40, 2)
++    assert c.from_locals(True, b"abc", b"x" * 40) == (b"abc", 1)
++    assert c.from_locals(False, b"abc", b"x" * 40) == (b"x" * 40, 2)
++    assert c.from_calls_flipped(True, b"x" * 40, b"abc") == (b"x" * 40, 2)
++    assert c.from_calls_flipped(False, b"x" * 40, b"abc") == (b"abc", 1)
++    assert c.from_locals_flipped(True, b"x" * 40, b"abc") == (b"x" * 40, 2)
++    assert c.from_locals_flipped(False, b"x" * 40, b"abc") == (b"abc", 1)
+diff --git a/vyper/codegen/core.py b/vyper/codegen/core.py
+index 2544e4d85..4fc339147 100644
+--- a/vyper/codegen/core.py
++++ b/vyper/codegen/core.py
+@@ -1218,6 +1218,33 @@ def _complex_make_setter(left, right, hi=None):
+         return b1.resolve(b2.resolve(IRnode.from_list(ret)))
+ 
+ 
++def punnable(src_typ, dst_typ):
++    """
++    Return True if memory laid out as `src_typ` can be read (punned) as `dst_typ`.
++
++    Compatible types can differ in element or member layout, e.g.
++    DynArray[Bytes[10], 5] vs DynArray[Bytes[512], 5] (element stride 64
++    vs 544). A wider bytestring bound or DynArray capacity at the top level
++    does not change the layout of the data that is present.
++    """
++    if isinstance(dst_typ, (DArrayT, SArrayT)):
++        assert isinstance(src_typ, (DArrayT, SArrayT))
++        pairs = [(src_typ.value_type, dst_typ.value_type)]
++    elif isinstance(dst_typ, TupleT):
++        assert isinstance(src_typ, TupleT)
++        n = len(dst_typ.member_types)
++        assert len(src_typ.member_types) == n
++        pairs = [(src_typ.member_types[i], dst_typ.member_types[i]) for i in range(n)]
++    else:
++        # primitive words, bytestrings ([length][data]) and (nominal) structs
++        return True
++
++    # nested values also need equal sizes: they determine strides and offsets
++    return all(
++        s.memory_bytes_required == d.memory_bytes_required and punnable(s, d) for s, d in pairs
++    )
++
++
+ def ensure_in_memory(ir_var, context):
+     """
+     Ensure a variable is in memory. This is useful for functions
+@@ -1229,8 +1256,9 @@ def ensure_in_memory(ir_var, context):
+     return create_memory_copy(ir_var, context)
+ 
+ 
+-def create_memory_copy(ir_var, context):
+-    typ = ir_var.typ
++def create_memory_copy(ir_var, context, typ=None):
++    if typ is None:
++        typ = ir_var.typ
+     buf = context.new_internal_variable(typ)
+     do_copy = make_setter(buf, ir_var)
+     return IRnode.from_list(["seq", do_copy, buf], typ=typ, location=MEMORY)
+diff --git a/vyper/codegen/expr.py b/vyper/codegen/expr.py
+index f829e39ad..3a455751a 100644
+--- a/vyper/codegen/expr.py
++++ b/vyper/codegen/expr.py
+@@ -8,6 +8,7 @@ from vyper.codegen.core import (
+     append_dyn_array,
+     check_assign,
+     clamp,
++    create_memory_copy,
+     data_location_to_address_space,
+     dummy_node_for_type,
+     ensure_in_memory,
+@@ -21,6 +22,7 @@ from vyper.codegen.core import (
+     make_setter,
+     pop_dyn_array,
+     potential_overlap,
++    punnable,
+     read_write_overlap,
+     sar,
+     shl,
+@@ -782,8 +784,19 @@ class Expr:
+         test = Expr.parse_value_expr(self.expr.test, self.context)
+         assert test.typ == BoolT()  # sanity check
+ 
+-        body = Expr(self.expr.body, self.context).ir_node
+-        orelse = Expr(self.expr.orelse, self.context).ir_node
++        typ = self.expr._metadata["type"]
++
++        def parse_arm(node):
++            arm = Expr(node, self.context).ir_node
++            # an arm can be narrower than the result type (e.g. DynArray[Bytes[10], 5]
++            # for a DynArray[Bytes[512], 5] result). the result is read with the
++            # result type's layout, so convert such arms element by element.
++            if punnable(arm.typ, typ):
++                return arm
++            return create_memory_copy(arm, self.context, typ=typ)
++
++        body = parse_arm(self.expr.body)
++        orelse = parse_arm(self.expr.orelse)
+ 
+         # if they are in the same location, we can skip copying
+         # into memory. also for the case where either body or orelse are
+@@ -797,7 +810,6 @@ class Expr:
+         # check this once compare_type has no side effects:
+         # assert body.typ.compare_type(orelse.typ)
+ 
+-        typ = self.expr._metadata["type"]
+         location = body.location
+         return IRnode.from_list(["if", test, body, orelse], typ=typ, location=location)
+ 

diff --git a/vyper-0006-fix-parser-fix-source-spans-for-form-feeds-and-non-a.patch b/vyper-0006-fix-parser-fix-source-spans-for-form-feeds-and-non-a.patch
new file mode 100644
index 0000000..9e8355e
--- /dev/null
+++ b/vyper-0006-fix-parser-fix-source-spans-for-form-feeds-and-non-a.patch
@@ -0,0 +1,319 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Kyle Cox <kshot9000@gmail.com>
+Date: Tue, 6 Oct 2026 13:47:50 +0000
+Subject: [PATCH] fix[parser]: fix source spans for form feeds and non-ascii
+ source
+
+The annotating visitor sliced node source code using line offsets built
+with str.splitlines() and CPython's col_offsets applied directly as
+character offsets. splitlines() also breaks on \x0b, \x0c, \x85 and
+U+2028/U+2029, which CPython does not treat as line boundaries, and
+col_offset is a UTF-8 byte offset, so any non-ASCII character earlier
+on a line displaced every following span. visit_Num re-derives Hex,
+Bytes and Decimal values from the sliced text, so affected literals
+silently compiled to values the source does not contain.
+
+Split lines the way CPython does (only \n, \r and \r\n are line
+boundaries) and convert byte column offsets to character offsets
+before slicing. Fixes #5292.
+
+[Backport to 0.4.3: squashed from the three commits of the still-unmerged
+upstream PR vyperlang/vyper#5294 (ca79f0ef1, d4f9b849b, 47768a977), using
+the PR's final state. Adapted to 0.4.3, where the line table is called
+`line_offsets`. Also skip a leading byte-order mark in `_char_index`: the
+pre-parser tokenizes bytes, which drops the BOM, so first-line col offsets
+do not count it; the PR as-is crashes with UnicodeDecodeError on such
+input, and unpatched 0.4.3 misreads first-line literals. Adds
+test_literal_source_spans_with_byte_order_mark. Fixes CVE-2026-114114
+(GHSA-r3c7-7xwm-6vfw) and GHSA-wvx7-39qj-2g9v.]
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/tests/unit/ast/test_parser.py b/tests/unit/ast/test_parser.py
+index 96df6cf24..257af0e44 100644
+--- a/tests/unit/ast/test_parser.py
++++ b/tests/unit/ast/test_parser.py
+@@ -1,5 +1,9 @@
++import pytest
++
+ from tests.ast_utils import deepequals
+ from vyper.ast.parse import parse_to_ast
++from vyper.compiler import compile_code
++from vyper.exceptions import InvalidLiteral
+ 
+ 
+ def test_ast_equal():
+@@ -34,3 +38,180 @@ def test() -> int128:
+     ast2 = parse_to_ast(code2)
+ 
+     assert not deepequals(ast1, ast2)
++
++
++_HEX_LITERAL = "0x1111111111111111111111111111111111111111"
++
++
++def _nodes_of_type(module_ast, ast_type):
++    return [n for n in module_ast.get_descendants() if n.ast_type == ast_type]
++
++
++@pytest.mark.parametrize(
++    "prefix",
++    [
++        "\x0c\n",  # form feed at the start of the file
++        "\n\x0c\n",  # form feed on its own line
++        "# café\n",  # non-ascii character on a previous line
++        "# \U0001f600\n",  # astral (surrogate-pair) character on a previous line
++        "# a\x0bb\n",  # vertical tab inside a comment
++        "# a\x85b\n",  # U+0085 (next line) inside a comment
++        "# a\u2028b\n",  # U+2028 inside a comment
++        "# a\u2029b\n",  # U+2029 inside a comment
++    ],
++)
++def test_literal_source_spans_with_offset_shifting_prefixes(prefix):
++    # the source spans (and therefore the literal values re-derived from
++    # them) must be identical no matter what precedes the literal: CPython
++    # reports byte-based column offsets and does not treat "\x0c" or
++    # U+2028 as line boundaries, so neither may shift the spans.
++    code = prefix + f"A: constant(address) = {_HEX_LITERAL}\n"
++    module_ast = parse_to_ast(code)
++
++    (hex_node,) = _nodes_of_type(module_ast, "Hex")
++    assert hex_node.node_source_code == _HEX_LITERAL
++    assert hex_node.value == _HEX_LITERAL
++
++    # every name must slice exactly its own identifier as well
++    assert [n.node_source_code for n in _nodes_of_type(module_ast, "Name")] == [
++        "A",
++        "constant",
++        "address",
++    ]
++
++
++def test_literal_source_spans_form_feed_at_end_of_line():
++    code = (
++        f"A: constant(address) = {_HEX_LITERAL}\x0c\n"
++        "B: constant(address) = 0x2222222222222222222222222222222222222222\n"
++    )
++    module_ast = parse_to_ast(code)
++    assert [n.value for n in _nodes_of_type(module_ast, "Hex")] == [
++        _HEX_LITERAL,
++        "0x2222222222222222222222222222222222222222",
++    ]
++
++
++def test_literal_source_span_nfkc_identifier():
++    # U+FB01 (3 utf-8 bytes, 1 character) NFKC-normalizes to the ascii name
++    # "fi"; the byte-based column offsets it produces must not displace the
++    # spans of the nodes that follow it on the same line.
++    code = f"fi: constant(address) = {_HEX_LITERAL}\n"
++    module_ast = parse_to_ast(code)
++
++    (hex_node,) = _nodes_of_type(module_ast, "Hex")
++    assert hex_node.node_source_code == _HEX_LITERAL
++    assert hex_node.value == _HEX_LITERAL
++    assert _nodes_of_type(module_ast, "Name")[0].node_source_code == "fi"
++
++
++def test_decimal_and_binary_literal_values_with_form_feed():
++    code = (
++        "\x0c\n"
++        "A: constant(decimal) = 1.5\n"
++        "B: constant(bytes4) = 0b11110000111100001111000011110000\n"
++    )
++    module_ast = parse_to_ast(code)
++
++    (decimal_node,) = _nodes_of_type(module_ast, "Decimal")
++    assert decimal_node.node_source_code == "1.5"
++    assert str(decimal_node.value) == "1.5"
++
++    (bytes_node,) = _nodes_of_type(module_ast, "Bytes")
++    assert bytes_node.node_source_code == "0b11110000111100001111000011110000"
++    assert bytes_node.value == b"\xf0\xf0\xf0\xf0"
++
++
++def test_decimal_and_binary_literal_values_after_multibyte_char():
++    # the decimal value is re-derived from the sliced source text, so a
++    # multi-byte character earlier on the line must not displace its span
++    code = (
++        "fi: constant(decimal) = 1.5\n" "B: constant(bytes4) = 0b11110000111100001111000011110000\n"
++    )
++    module_ast = parse_to_ast(code)
++
++    (decimal_node,) = _nodes_of_type(module_ast, "Decimal")
++    assert decimal_node.node_source_code == "1.5"
++    assert str(decimal_node.value) == "1.5"
++
++    (bytes_node,) = _nodes_of_type(module_ast, "Bytes")
++    assert bytes_node.node_source_code == "0b11110000111100001111000011110000"
++    assert bytes_node.value == b"\xf0\xf0\xf0\xf0"
++
++
++@pytest.mark.parametrize(
++    "char",
++    [
++        "\x0b",  # vertical tab
++        "\x0c",  # form feed
++        "\x85",  # next line
++        "\u2028",  # line separator
++        "\u2029",  # paragraph separator
++    ],
++)
++def test_splitlines_only_characters_in_comments_do_not_shift_spans(char):
++    # these characters are line boundaries for str.splitlines() but not
++    # for CPython's tokenizer, so they may not shift the line numbers
++    # (and spans) of the code that follows them.
++    code = (
++        f"A: constant(address) = {_HEX_LITERAL}\n"
++        f"# comment{char}here\n"
++        "B: constant(address) = 0x2222222222222222222222222222222222222222\n"
++    )
++    module_ast = parse_to_ast(code)
++    assert [n.value for n in _nodes_of_type(module_ast, "Hex")] == [
++        _HEX_LITERAL,
++        "0x2222222222222222222222222222222222222222",
++    ]
++    assert [n.node_source_code for n in _nodes_of_type(module_ast, "Name")] == [
++        "A",
++        "constant",
++        "address",
++        "B",
++        "constant",
++        "address",
++    ]
++
++
++def test_line_separator_in_string_literal():
++    # U+2028 inside a string literal is content, not a line boundary.
++    # vyper rejects non-ascii string literals, but the rejection must
++    # point at the right place: the node's span must slice exactly the
++    # literal from the source, on the line the parser reports.
++    code = "\x0c\n" + 'A: constant(String[4]) = "a\u2028b"\n'
++    with pytest.raises(InvalidLiteral) as exc_info:
++        parse_to_ast(code)
++
++    (annotation,) = exc_info.value.annotations
++    assert annotation.lineno == 2
++    assert annotation.node_source_code == '"a\u2028b"'
++
++
++def test_form_feed_contract_compiles_to_same_runtime_bytecode():
++    code = (
++        f"A: constant(address) = {_HEX_LITERAL}\n\n@external\ndef get() -> address:\n    return A\n"
++    )
++    out = compile_code(code, output_formats=["bytecode_runtime"])
++    out_ff = compile_code("\x0c\n" + code, output_formats=["bytecode_runtime"])
++    assert out_ff["bytecode_runtime"] == out["bytecode_runtime"]
++
++
++def test_escaped_form_feed_in_bytes_literal_allowed():
++    # the escape sequence (four ascii characters in the source text)
++    # is ordinary source text and parses as usual.
++    code = 'A: constant(bytes1) = b"\\x0c"\n'
++    module_ast = parse_to_ast(code)
++
++    (bytes_node,) = _nodes_of_type(module_ast, "Bytes")
++    assert bytes_node.value == b"\x0c"
++
++
++def test_literal_source_spans_with_byte_order_mark():
++    # the pre-parser tokenizes bytes, which drops a leading byte-order mark,
++    # so first-line spans must not be shifted by it.
++    code = f"A: constant(address) = {_HEX_LITERAL}  # 0x2222\n"
++    module_ast = parse_to_ast(code)
++
++    (hex_node,) = _nodes_of_type(module_ast, "Hex")
++    assert hex_node.node_source_code == _HEX_LITERAL
++    assert hex_node.value == _HEX_LITERAL
+diff --git a/vyper/ast/parse.py b/vyper/ast/parse.py
+index 9836fd166..3af7e0f18 100644
+--- a/vyper/ast/parse.py
++++ b/vyper/ast/parse.py
+@@ -198,7 +198,34 @@ class AnnotatingVisitor(python_ast.NodeTransformer):
+ 
+     @cached_property
+     def source_lines(self):
+-        return self._source_code.splitlines(keepends=True)
++        # Split the source the way CPython's tokenizer does: only "\n",
++        # "\r" and "\r\n" are line boundaries. str.splitlines() also splits
++        # on "\x0b", "\x0c", "\x85", U+2028 and U+2029, none of which start
++        # a new line for the python parser, so using it here desynchronises
++        # our line numbers (and every span derived from them) from the
++        # positions reported by the python AST whenever the source contains
++        # one of those characters.
++        lines = []
++        start = 0
++        i = 0
++        source = self._source_code
++        while i < len(source):
++            c = source[i]
++            if c == "\n":
++                i += 1
++                lines.append(source[start:i])
++                start = i
++            elif c == "\r":
++                i += 1
++                if i < len(source) and source[i] == "\n":
++                    i += 1
++                lines.append(source[start:i])
++                start = i
++            else:
++                i += 1
++        if start < len(source):
++            lines.append(source[start:])
++        return lines
+ 
+     @cached_property
+     def line_offsets(self):
+@@ -210,6 +237,30 @@ class AnnotatingVisitor(python_ast.NodeTransformer):
+             ofst += len(line)
+         return ret
+ 
++    def _char_index(self, lineno: int, byte_col_offset: int) -> int:
++        """
++        Convert a (lineno, col_offset) pair from the python AST into a
++        character index into `self._source_code`.
++
++        `col_offset` values (including the pre-parser's shift adjustments,
++        which are computed from tokenize positions) are UTF-8 *byte* offsets
++        within the line, while `line_offsets` and string slicing work in
++        characters. For lines containing non-ASCII characters the two
++        disagree, and slicing with the raw byte offset returns source text
++        that does not correspond to the node.
++        """
++        line_start = self.line_offsets[lineno]
++        line = self.source_lines[lineno - 1] if self.source_lines else ""
++        # the pre-parser tokenizes bytes, which drops a leading byte-order
++        # mark, so col offsets on the first line do not count it.
++        if lineno == 1 and line.startswith("\ufeff"):
++            line_start += 1
++            line = line[1:]
++        if byte_col_offset == 0:
++            return line_start
++        char_col_offset = len(line.encode("utf-8")[:byte_col_offset].decode("utf-8"))
++        return line_start + char_col_offset
++
+     def start(self, node: python_ast.Module):
+         self._fix_missing_locations(node)
+         self.visit(node)
+@@ -227,7 +278,8 @@ class AnnotatingVisitor(python_ast.NodeTransformer):
+         ast_node.end_lineno = max(1, len(self.source_lines))
+ 
+         if len(self.source_lines) > 0:
+-            ast_node.end_col_offset = len(self.source_lines[-1])
++            # col offsets are utf-8 byte offsets (see `_char_index`)
++            ast_node.end_col_offset = len(self.source_lines[-1].encode("utf-8"))
+         else:
+             ast_node.end_col_offset = 0
+ 
+@@ -272,8 +324,8 @@ class AnnotatingVisitor(python_ast.NodeTransformer):
+         adj = adjustments.get((node.end_lineno, node.end_col_offset), 0)
+         node.end_col_offset += adj
+ 
+-        start_pos = self.line_offsets[node.lineno] + node.col_offset
+-        end_pos = self.line_offsets[node.end_lineno] + node.end_col_offset
++        start_pos = self._char_index(node.lineno, node.col_offset)
++        end_pos = self._char_index(node.end_lineno, node.end_col_offset)
+ 
+         node.src = f"{start_pos}:{end_pos-start_pos}:{self._source_id}"
+         node.node_source_code = self._source_code[start_pos:end_pos]

diff --git a/vyper-0007-fix-codegen-check-create_from_blueprint-code_offset-.patch b/vyper-0007-fix-codegen-check-create_from_blueprint-code_offset-.patch
new file mode 100644
index 0000000..f9d85bc
--- /dev/null
+++ b/vyper-0007-fix-codegen-check-create_from_blueprint-code_offset-.patch
@@ -0,0 +1,81 @@
+From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
+From: Peter Lemenkov <lemenkov@gmail.com>
+Date: Tue, 3 Nov 2026 07:23:41 +0100
+Subject: [PATCH] fix[codegen]: check `create_from_blueprint` code_offset
+ before subtracting
+
+The legacy codegen computed the blueprint's remaining size as
+`extcodesize(target) - code_offset` and validated the result with a
+signed `sgt(codesize, 0)`. code_offset is a uint256 and can come from
+the caller, so the subtraction can wrap to a small positive value
+(e.g. 200 - (2**256 - 1) = 201) that passes the check. EXTCODECOPY then
+reads past the end of the blueprint, the zero-filled initcode starts
+with STOP, and the call deploys a contract with empty runtime code
+instead of reverting.
+
+Compare `code_offset < extcodesize(target)` unsigned, before the
+subtraction. This mirrors the venom codegen fix upstream (d3c150e4a,
+"feat[venom]: wire up dyn allocations"), which has no legacy
+counterpart on master yet.
+
+Fixes CVE-2026-114118 (GHSA-fxg7-4wqg-c8gh).
+
+Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
+Signed-off-by: Peter Lemenkov <lemenkov@gmail.com>
+
+diff --git a/tests/functional/builtins/codegen/test_create_functions.py b/tests/functional/builtins/codegen/test_create_functions.py
+index 085d01275..1dac74110 100644
+--- a/tests/functional/builtins/codegen/test_create_functions.py
++++ b/tests/functional/builtins/codegen/test_create_functions.py
+@@ -319,6 +319,12 @@ def test(code_ofst: uint256) -> address:
+     with tx_failed():
+         d.test(EIP_170_LIMIT)
+ 
++    # offsets that wrap (extcodesize - code_offset) around to a small
++    # positive value must not deploy an empty contract
++    for code_ofst in (2**256 - 1, 2**256 - initcode_len, 2**255):
++        with tx_failed():
++            d.test(code_ofst)
++
+ 
+ # test create_from_blueprint with args
+ def test_create_from_blueprint_args(
+diff --git a/vyper/builtins/functions.py b/vyper/builtins/functions.py
+index 11508d7dd..21a257d9b 100644
+--- a/vyper/builtins/functions.py
++++ b/vyper/builtins/functions.py
+@@ -1806,24 +1806,27 @@ class CreateFromBlueprint(_CreateBase):
+             (target, value, salt, argslen, code_offset),
+             ("create_target", "create_value", "create_salt", "encoded_args_len", "code_offset"),
+         ) as (b1, (target, value, salt, encoded_args_len, code_offset)):
+-            codesize = IRnode.from_list(["sub", ["extcodesize", target], code_offset])
++            extcodesize = IRnode.from_list(["extcodesize", target])
+             # copy code to memory starting from msize. we are clobbering
+             # unused memory so it's safe.
+             msize = IRnode.from_list(["msize"], location=MEMORY)
+-            with scope_multi((codesize, msize), ("target_codesize", "mem_ofst")) as (
++            with scope_multi((extcodesize, msize), ("target_extcodesize", "mem_ofst")) as (
+                 b2,
+-                (codesize, mem_ofst),
++                (extcodesize, mem_ofst),
+             ):
++                codesize = IRnode.from_list(["sub", extcodesize, code_offset])
+                 ir = ["seq"]
+ 
+                 # make sure there is code at the target, and that
+-                # code_ofst <= (extcodesize target).
+-                # (note if code_ofst > (extcodesize target), would be
+-                # OOG on the EXTCODECOPY)
++                # code_ofst < (extcodesize target).
+                 # (code_ofst == (extcodesize target) would be empty
+                 # initcode, which we disallow for hygiene reasons -
+                 # same as `create_copy_of` on an empty target).
+-                check_codesize = ["assert", ["sgt", codesize, 0]]
++                # the comparison must be unsigned and done before the
++                # subtraction: code_ofst is a uint256 and can be
++                # attacker-controlled, and a wrapped difference such as
++                # (extcodesize target) - (2**256 - 1) passes a signed check.
++                check_codesize = ["assert", ["gt", extcodesize, code_offset]]
+                 ir.append(
+                     IRnode.from_list(
+                         check_codesize, error_msg="empty target (create_from_blueprint)"

diff --git a/vyper.spec b/vyper.spec
index 7235dd1..966e1cb 100644
--- a/vyper.spec
+++ b/vyper.spec
@@ -7,12 +7,21 @@ Release:	%autorelease
 BuildArch:	noarch
 License:	Apache-2.0
 URL:		https://vyperlang.org
-Source0:	%{pypi_source %{name}}
+Source:		%{pypi_source %{name}}
 # Fedora-specific
 Patch:		vyper-0001-Use-Cryptodomex.patch
 # Reverts https://github.com/vyperlang/vyper/pull/3613
 Patch:		vyper-0002-Ease-version-requirements.patch
+# Fedora-specific
 Patch:		vyper-0003-Remove-unnecessary-shebang.patch
+# Fedora-specific
+Patch:		vyper-0004-Relax-lark-dependency.patch
+# Backported from upstream
+Patch:		vyper-0005-fix-codegen-widen-ternary-arms-to-the-result-type-la.patch
+# Backported from upstream
+Patch:		vyper-0006-fix-parser-fix-source-spans-for-form-feeds-and-non-a.patch
+# Backported from upstream
+Patch:		vyper-0007-fix-codegen-check-create_from_blueprint-code_offset-.patch
 BuildRequires:	git
 BuildRequires:	python3-cached_property
 BuildRequires:	python3-eth-abi

                 reply	other threads:[~2026-11-03  6:44 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=179368826836.1.3973312442517479262.rpms-vyper-4465058cf6ab@fedoraproject.org \
    --to=lemenkov@gmail.com \
    --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