RV64 Linux ELF loader reuses the same AT_RANDOM bytes for every process

Offen Anfängerfreundlich
#1,692 0 Kommentare 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

@carlosqwqqwq arbeitet bereits daran.

Seit 23.11.2026.

  • #1693 von @carlosqwqqwq — offen

Bewertung

Schwierigkeit
2/5
Geschätzter Aufwand
1-3 Stunden
Anfängerfreundlichkeit
64/100
Issue-Typ
Bug
Klarheit
Klar beschrieben
Aktivitätsstatus
Aktiv
Tech-Stack
linux, python

Rechercherichtung

Suche im Qiling-Quellcode nach dem Auxiliary-Vector-Setup und dem Literal 'a' * 16; der Linux-ELF-Loader ist der Einstiegspunkt, und der Fix gehört dorthin, wo AT_RANDOM seinen Zeiger erhält. Baue probe.elf wie beschrieben, führe die Python-Schleife aus und vergleiche wiederholte 16-Byte-Ausgaben; QEMU user output ist die Referenz. Fertig bedeutet, dass jeder Qiling-Start einen anderen 16-Byte-Seed liefert, während der Rest des auxv-Layouts weiterhin funktioniert.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

Describe the bug

A static RV64 Linux ELF that reads the 16 bytes referenced by auxiliary-vector entry AT_RANDOM receives the same bytes on every Qiling launch. On the current dev branch, the loader builds this buffer from the literal 'a' * 16.

Sample Code

Save as probe.S:

.option push
.option norelax
.section .text
.globl _start
_start:
    ld t0, 0(sp)
    addi t1, sp, 8
    slli t2, t0, 3
    add t1, t1, t2
    addi t1, t1, 8
.Lskip_env:
    ld t3, 0(t1)
    beqz t3, .Lenv_end
    addi t1, t1, 8
    j .Lskip_env
.Lenv_end:
    addi t1, t1, 8
    li t5, 25
.Lauxv:
    ld t3, 0(t1)
    beqz t3, .Lnot_found
    ld t4, 8(t1)
    beq t3, t5, .Lfound
    addi t1, t1, 16
    j .Lauxv
.Lfound:
    li a0, 1
    mv a1, t4
    li a2, 16
    li a7, 64
    ecall
    li a0, 0
    li a7, 93
    ecall
.Lnot_found:
    li a0, 2
    li a7, 93
    ecall
.option pop
Expected behavior

AT_RANDOM should point to 16 process-specific random bytes. Repeated launches should not all return the fixed sequence 61 repeated 16 times.

Reproduction

With a RISC-V cross-binutils toolchain and QEMU user emulator installed:

riscv64-linux-gnu-as -march=rv64imac -mabi=lp64 -o probe.o probe.S
riscv64-linux-gnu-ld -m elf64lriscv -static -e _start -o probe.elf probe.o
for i in 1 2 3; do qemu-riscv64 ./probe.elf | od -An -tx1; done

From an installed checkout of Qiling dev, run:

from qiling import Qiling
from qiling.const import QL_ARCH, QL_OS, QL_VERBOSE
for _ in range(3):
    ql = Qiling(["./probe.elf"], ".", archtype=QL_ARCH.RISCV64,
                 ostype=QL_OS.LINUX, verbose=QL_VERBOSE.DISABLED)
    ql.run()

Qiling prints the same 16-byte 0x61 sequence on each run; QEMU user returns different 16-byte values.

Additional context

Linux uses AT_RANDOM as a process-specific seed in the initial ELF stack. This report is limited to the guest-visible bytes and does not claim a particular exploit.

References: Linux ELF loader · QEMU user ELF loader

Vorherrschende Sprache
Python
Sterne
6.2k
Forks
809
PR-Merge-Kennzahlen
Keine gemergten PRs in 30 T.

Entwicklungsumgebung

  • Enthält ein Dockerfile oder eine Docker-Compose-Datei
  • Hat eine Pull-Request-Vorlage
  • Kein Beitragsleitfaden

Erste Schritte

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus qilingframework/qiling

Alle Issues in qilingframework/qiling

Ähnliche Issues

Weitere Issues zu Python

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.