public inbox for glibc-bugs@sourceware.org help / color / mirror / Atom feed
From: "npv1310 at gmail dot com" <sourceware-bugzilla@sourceware.org> To: glibc-bugs@sourceware.org Subject: [Bug libc/28524] New: Conversion from ISO-2022-JP-3 with iconv may emit spurious NUL character on state reset Date: Mon, 01 Nov 2021 17:48:27 +0000 [thread overview] Message-ID: <bug-28524-131@http.sourceware.org/bugzilla/> (raw) https://sourceware.org/bugzilla/show_bug.cgi?id=28524 Bug ID: 28524 Summary: Conversion from ISO-2022-JP-3 with iconv may emit spurious NUL character on state reset Product: glibc Version: unspecified Status: UNCONFIRMED Severity: normal Priority: P2 Component: libc Assignee: unassigned at sourceware dot org Reporter: npv1310 at gmail dot com CC: drepper.fsp at gmail dot com Target Milestone: --- Created attachment 13751 --> https://sourceware.org/bugzilla/attachment.cgi?id=13751&action=edit Proof of concept Hello, while investigating CVE-2021-3326 patch [here: https://sourceware.org/git/?p=glibc.git;a=commit;h=7d88c6142c6efc160c0ee5e4f85cde382c072888] I've found that it is possible to force iconv() to emit spurious NUL character by converting from ISO-2022-JP-3 encoding and resetting internal state (inbuf = NULL). This is possible because code sequence in iconvdata/iso-2022-jp-3.c which is responsible for resetting internal state doesn't ensure that any character has actually been saved. The main condition [data->__statep->__count != ASCII_set] also picks a cases where current set is different from ASCII_set. I've written small proof-of-concept which is attached. In a research environment, proof-of-concept program was compiled with following command sequence: $ gcc iconv-issue.c -c -Wall -o /tmp/iconv-issue.o $ gcc -o /tmp/iconv-issue -nostdlib -nostartfiles /root/glibc-build/csu/Scrt1.o /root/glibc-build/csu/crti.o `gcc --print-file-name=crtbeginS.o` /tmp/iconv-issue.o -Wl,-rpath-link=/root/glibc-build:/root/glibc-build/math:/root/glibc-build/elf:/root/glibc-build/dlfcn:/root/glibc-build/nss:/root/glibc-build/nis:/root/glibc-build/rt:/root/glibc-build/resolv:/root/glibc-build/mathvec:/root/glibc-build/support:/root/glibc-build/crypt:/root/glibc-build/nptl /root/glibc-build/libc.so.6 `gcc --print-file-name=crtendS.o` /root/glibc-build/csu/crtn.o $ env GCONV_PATH=/root/glibc-build/iconvdata LOCPATH=/root/glibc-build/localedata LC_ALL=C /root/glibc-build/elf/ld-linux-x86-64.so.2 --library-path /root/glibc-build:/root/glibc-build/math:/root/glibc-build/elf:/root/glibc-build/dlfcn:/root/glibc-build/nss:/root/glibc-build/nis:/root/glibc-build/rt:/root/glibc-build/resolv:/root/glibc-build/mathvec:/root/glibc-build/support:/root/glibc-build/crypt:/root/glibc-build/nptl /tmp/iconv-issue Here /root/glibc-build is a build root for up-to-date version of glibc. The last command results in a following output: Step#1 Input characters consumed = 3 Output characters produced = 0 Step#2 Output characters produced = 1 With glibc lacking CVE-2021-3326 fix output is normal: Step#1 Input characters consumed = 3 Output characters produced = 0 Step#2 Output characters produced = 0 I assess that this behavior may affect data integrity in certain use patterns of iconv where extra data ('\0') is added. Such NUL character may confuse programs expecting NUL as the data terminator. -- You are receiving this mail because: You are on the CC list for the bug.
next reply other threads:[~2021-11-01 17:48 UTC|newest] Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top 2021-11-01 17:48 npv1310 at gmail dot com [this message] 2021-11-02 10:13 ` [Bug libc/28524] " fweimer at redhat dot com 2021-11-04 5:18 ` npv1310 at gmail dot com 2021-11-04 19:32 ` fweimer at redhat dot com 2021-11-05 21:32 ` sam at gentoo dot org 2021-11-08 16:30 ` siddhesh at sourceware dot org 2021-11-08 17:24 ` npv1310 at gmail dot com 2021-11-08 17:37 ` siddhesh at sourceware dot org 2021-11-08 17:54 ` fweimer at redhat dot com 2023-05-22 19:01 ` bruno at clisp dot org 2023-05-22 19:04 ` bruno at clisp dot org
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=bug-28524-131@http.sourceware.org/bugzilla/ \ --to=sourceware-bugzilla@sourceware.org \ --cc=glibc-bugs@sourceware.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: linkBe 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; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).