selinux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: James Carter <jwcart2@gmail.com>
To: Nicolas Iooss <nicolas.iooss@m4x.org>
Cc: SElinux list <selinux@vger.kernel.org>
Subject: Re: [PATCH] libsepol/cil: do not allow \0 in quoted strings
Date: Mon, 12 Jul 2021 10:36:20 -0400	[thread overview]
Message-ID: <CAP+JOzR-xRuU9x4qm5Ndp-wbjgxHj2UDxwdcvkGSxTg912=snw@mail.gmail.com> (raw)
In-Reply-To: <20210712084428.73440-1-nicolas.iooss@m4x.org>

On Mon, Jul 12, 2021 at 4:54 AM Nicolas Iooss <nicolas.iooss@m4x.org> wrote:
>
> Using the '\0' character in strings in a CIL policy is not expected to
> happen, and makes the flex tokenizer very slow. For example when
> generating a file with:
>
>     python -c 'print("\"" + "\0"*100000 + "\"")' > policy.cil
>
> secilc fails after 26 seconds, on my desktop computer. Increasing the
> numbers of \0 makes this time increase significantly. But replacing \0
> with another character makes secilc fail in only few milliseconds.
>
> Fix this "possible denial of service" issue by forbidding \0 in strings
> in CIL policies.
>
> Fixes: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=36016
>
> Signed-off-by: Nicolas Iooss <nicolas.iooss@m4x.org>

Acked-by: James Carter <jwcart2@gmail.com>

> ---
>  libsepol/cil/src/cil_lexer.l | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/libsepol/cil/src/cil_lexer.l b/libsepol/cil/src/cil_lexer.l
> index e28c33ecb9f1..8bf2b6e7765a 100644
> --- a/libsepol/cil/src/cil_lexer.l
> +++ b/libsepol/cil/src/cil_lexer.l
> @@ -49,7 +49,7 @@ spec_char     [\[\]\.\@\=\/\*\-\_\$\%\+\-\!\|\&\^\:\~\`\#\{\}\'\<\>\?\,]
>  symbol         ({digit}|{alpha}|{spec_char})+
>  white          [ \t]
>  newline                [\n\r]
> -qstring                \"[^"\n]*\"
> +qstring                \"[^"\n\0]*\"
>  hll_lm          ^;;\*
>  comment                ;
>
> --
> 2.32.0
>

  reply	other threads:[~2021-07-12 14:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-12  8:44 [PATCH] libsepol/cil: do not allow \0 in quoted strings Nicolas Iooss
2021-07-12 14:36 ` James Carter [this message]
2021-07-13 20:00   ` Nicolas Iooss

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='CAP+JOzR-xRuU9x4qm5Ndp-wbjgxHj2UDxwdcvkGSxTg912=snw@mail.gmail.com' \
    --to=jwcart2@gmail.com \
    --cc=nicolas.iooss@m4x.org \
    --cc=selinux@vger.kernel.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: link
Be 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 NNTP newsgroup(s).