Vector35 / Vector35/binaryninja-api

Non null-terminated ASCII string leads to truncated string annotation

Open
#2,222 4 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Component: UI Effort: Low Impact: Medium UI: Strings
Dominant language
C++
Stars
1.3k
Forks
298
Avg merge
5d 5h
Merged PRs (30d)
19

Description

Binary Ninja Version: 2.2.2487 Personal, e0eb0a77
Platform: Ubuntu 20.04.1 LTS

I noticed that I can get the following result in binary ninja:

syscall(sys_write {1}, fd: 2, buf: "abcd", count: 6)

While I expected to see buf as "abcde\n".

Here's the code of the small repro program that results in the above disassembly

bits 64

section .rodata
        str:       db 'abcde',10
        strLen:    dq $ - str

section .text
        global _start

_start:
        mov rax, 1
        mov rdi, 2
        lea rsi, [rel str]
        mov rdx, [rel strLen] 
        syscall

        mov rax, 60
        mov rdi, 0
        syscall

I assembled and linked it with

nasm -f elf64 issue.s -o issue.o && ld ./issue.o -o issue

It's not a pressing issue on my end, but I thought that you may want to know.

(I haven't tested if this issue generalizes to other scenarios).

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the report with the provided NASM program and the shown syscall output, then investigate Binary Ninja's string annotation handling for non-null-terminated ASCII data. Done means the buffer annotation represents the full length-delimited value, including the trailing newline, rather than truncating at the observed boundary.

Written by the indexing model from the issue text.

Assessment

Domain
reverse-engineering
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
38/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.