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

未关闭 适合新手
#1,692 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@carlosqwqqwq 已经在做这个了。

开始于 2026年11月23日。

  • #1693 来自 @carlosqwqqwq —— 未关闭

评估

难度
2/5
预计耗时
1-3 小时
新手友好度
64/100
Issue 类型
缺陷
描述清晰度
描述清楚
活跃度
活跃
技术栈
linux, python

调研方向

在 Qiling 源码中搜索 auxiliary-vector 设置和字面量 'a' * 16;Linux ELF loader 是入口点,修复应位于 AT_RANDOM 接收其指针的位置。按描述构建 probe.elf,运行 Python 循环,并比较重复的 16 字节输出;QEMU user output 是参照。完成意味着每次启动 Qiling 都会产生不同的 16 字节种子,同时 auxv 布局的其余部分仍然正常工作。

由索引模型根据 Issue 内容生成。

描述

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

主要语言
Python
星标
6.2k
派生
809
PR 合并指标
30 天内没有已合并 PR

环境准备

  • 提供 Dockerfile 或 Docker Compose 文件
  • 有 Pull Request 模板
  • 没有贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

qilingframework/qiling 的其他 Issue

查看 qilingframework/qiling 的全部 Issue

相似的 Issue

更多 Python Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。