Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (Cyborg)
  • No Skin
Collapse
Brand Logo

CIRCLE WITH A DOT

  1. Home
  2. Uncategorized
  3. Zipbomb JSON.

Zipbomb JSON.

Scheduled Pinned Locked Moved Uncategorized
18 Posts 11 Posters 13 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • jwz@mastodon.socialJ jwz@mastodon.social

    Zipbomb JSON.

    Someone who is not me should formulate a maximally-malicious JSON file. I made one with a nesting depth of ~182 million, but "jq" gives up early, at only around depth 3,000. So one trick would be to find the right balance of nesting and array length that stays under typical parsers' limits as long as possible, while requiring as much RAM as possible to get there.
    https://jwz.org/b/yk2x

    zegnat@chaos.socialZ This user is from outside of this forum
    zegnat@chaos.socialZ This user is from outside of this forum
    zegnat@chaos.social
    wrote last edited by
    #7

    @jwz it has always been surprisingly hard to crash JSON parsers, or even to get them to time out. See https://seriot.ch/software/parsing_json.html.

    If attacking the parser is not an option, we are back to filling memory, which can probably be done by using really big strings. Presumably you do not want to store and transfer all those bytes, so you gzip them, and then it is just a gzip bomb with an extra layer: gzip bomb needs to expand into something that seems like JSON to the parser.

    1 Reply Last reply
    0
    • jwz@mastodon.socialJ jwz@mastodon.social

      Zipbomb JSON.

      Someone who is not me should formulate a maximally-malicious JSON file. I made one with a nesting depth of ~182 million, but "jq" gives up early, at only around depth 3,000. So one trick would be to find the right balance of nesting and array length that stays under typical parsers' limits as long as possible, while requiring as much RAM as possible to get there.
      https://jwz.org/b/yk2x

      danfuzz@mastodon.socialD This user is from outside of this forum
      danfuzz@mastodon.socialD This user is from outside of this forum
      danfuzz@mastodon.social
      wrote last edited by
      #8

      @jwz I have no visibility into your bot traffic, apologies if this is useless: If they send `Accept-Encoding: ...br...` you can hand out a Brotli file with much higher compression than gzip. I did an ad-hoc test of compressing `[[[...]]]` with 100 million layers, and the resulting compressed file was ~350 bytes.

      jwz@mastodon.socialJ 1 Reply Last reply
      0
      • danfuzz@mastodon.socialD danfuzz@mastodon.social

        @jwz I have no visibility into your bot traffic, apologies if this is useless: If they send `Accept-Encoding: ...br...` you can hand out a Brotli file with much higher compression than gzip. I did an ad-hoc test of compressing `[[[...]]]` with 100 million layers, and the resulting compressed file was ~350 bytes.

        jwz@mastodon.socialJ This user is from outside of this forum
        jwz@mastodon.socialJ This user is from outside of this forum
        jwz@mastodon.social
        wrote last edited by
        #9

        @danfuzz I tried that, but Brotli is not widely supported, even by Google. It is the WebP of compression algorithms.

        1 Reply Last reply
        0
        • developing_agent@mastodon.socialD developing_agent@mastodon.social

          @prozacchiwawa @jwz Are there good resources on how to armor parsers against this sort of thing? Without having to resort to "run this thing in a padded cell cgroup with limited CPU percent and limited execution time"? (since that's not very portable to say, a microcontroller)

          sowophie@chaos.socialS This user is from outside of this forum
          sowophie@chaos.socialS This user is from outside of this forum
          sowophie@chaos.social
          wrote last edited by
          #10

          @developing_agent @prozacchiwawa @jwz The first component in the parser is gonna be some kind of loop iterating over input tokens. Recognition of a single token is typically either O(1) (e.g. punctuation) or built from O(1) subtasks (e.g. literals). Putting something like

          if (++work > LIMIT) abandon_ship();

          after each of these might be worth a shot.

          1 Reply Last reply
          0
          • jwz@mastodon.socialJ jwz@mastodon.social

            Zipbomb JSON.

            Someone who is not me should formulate a maximally-malicious JSON file. I made one with a nesting depth of ~182 million, but "jq" gives up early, at only around depth 3,000. So one trick would be to find the right balance of nesting and array length that stays under typical parsers' limits as long as possible, while requiring as much RAM as possible to get there.
            https://jwz.org/b/yk2x

            jwz@mastodon.socialJ This user is from outside of this forum
            jwz@mastodon.socialJ This user is from outside of this forum
            jwz@mastodon.social
            wrote last edited by
            #11

            Ok FINE, since you have all failed me, I wrote my own JSON bomb generator. https://jwz.org/b/yk2x

            ricko@tech.lgbtR evilotto@sfba.socialE jsatk@sfba.socialJ 3 Replies Last reply
            1
            0
            • jwz@mastodon.socialJ jwz@mastodon.social

              Ok FINE, since you have all failed me, I wrote my own JSON bomb generator. https://jwz.org/b/yk2x

              ricko@tech.lgbtR This user is from outside of this forum
              ricko@tech.lgbtR This user is from outside of this forum
              ricko@tech.lgbt
              wrote last edited by
              #12

              @jwz In make_string you set $bt to an escaped version of $base_text, but then all the concatenations after that use $base_text instead of $bt. It seems like this is a mistake, as the final quotes at the end seem like they should be surrounding escaped text. Or did I miss something?

              jwz@mastodon.socialJ 1 Reply Last reply
              0
              • jwz@mastodon.socialJ jwz@mastodon.social

                Ok FINE, since you have all failed me, I wrote my own JSON bomb generator. https://jwz.org/b/yk2x

                evilotto@sfba.socialE This user is from outside of this forum
                evilotto@sfba.socialE This user is from outside of this forum
                evilotto@sfba.social
                wrote last edited by
                #13

                @jwz I can't help but smile a little that people are still using perl to make the internet a better place.

                1 Reply Last reply
                0
                • ricko@tech.lgbtR ricko@tech.lgbt

                  @jwz In make_string you set $bt to an escaped version of $base_text, but then all the concatenations after that use $base_text instead of $bt. It seems like this is a mistake, as the final quotes at the end seem like they should be surrounding escaped text. Or did I miss something?

                  jwz@mastodon.socialJ This user is from outside of this forum
                  jwz@mastodon.socialJ This user is from outside of this forum
                  jwz@mastodon.social
                  wrote last edited by
                  #14

                  @ricko Thanks. I guess It'll go over the limit slightly if you use text it has to escape.

                  ricko@tech.lgbtR 1 Reply Last reply
                  0
                  • jwz@mastodon.socialJ jwz@mastodon.social

                    @ricko Thanks. I guess It'll go over the limit slightly if you use text it has to escape.

                    ricko@tech.lgbtR This user is from outside of this forum
                    ricko@tech.lgbtR This user is from outside of this forum
                    ricko@tech.lgbt
                    wrote last edited by
                    #15

                    @jwz For the lols, I've ported this to TypeScript and published it to npm. So people who fear perl but have some moderately modern version of node installed can do:

                    npx @rickosborne/jsonbomb@latest
                    # or, with args
                    npx @rickosborne/jsonbomb@latest --max-size 1G | gzip --best > bomb.json.gz

                    Licensed under the same terms as yours, with lots of README and source linkage back to yours.

                    1 Reply Last reply
                    0
                    • jwz@mastodon.socialJ jwz@mastodon.social

                      Ok FINE, since you have all failed me, I wrote my own JSON bomb generator. https://jwz.org/b/yk2x

                      jsatk@sfba.socialJ This user is from outside of this forum
                      jsatk@sfba.socialJ This user is from outside of this forum
                      jsatk@sfba.social
                      wrote last edited by
                      #16

                      @jwz in Perl no less!

                      jwz@mastodon.socialJ 1 Reply Last reply
                      0
                      • jsatk@sfba.socialJ jsatk@sfba.social

                        @jwz in Perl no less!

                        jwz@mastodon.socialJ This user is from outside of this forum
                        jwz@mastodon.socialJ This user is from outside of this forum
                        jwz@mastodon.social
                        wrote last edited by
                        #17

                        @jsatk I like languages that are *stable* and don't require me to have 7 different versions installed at once.

                        jsatk@sfba.socialJ 1 Reply Last reply
                        0
                        • jwz@mastodon.socialJ jwz@mastodon.social

                          @jsatk I like languages that are *stable* and don't require me to have 7 different versions installed at once.

                          jsatk@sfba.socialJ This user is from outside of this forum
                          jsatk@sfba.socialJ This user is from outside of this forum
                          jsatk@sfba.social
                          wrote last edited by
                          #18

                          @jwz brother I hear you. As someone who has written JavaScript for 17 years I’m exhausted by all the changes to it and node.

                          1 Reply Last reply
                          0
                          • R relay@relay.infosec.exchange shared this topic
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups