Giter Site home page Giter Site logo

Flawed Encryption Logic about ectoken HOT 2 CLOSED

edgio avatar edgio commented on August 24, 2024
Flawed Encryption Logic

from ectoken.

Comments (2)

jcline avatar jcline commented on August 24, 2024 1

Hi!

I think I understand how this could be confusing.

There's a couple parts to this which I will attempt to illustrate. I've also created a new test which validates the behavior is as I describe below.

base64 encoders work by taking ever 6 bits of an input and mapping those to an ASCII character. If the number of bits in the input is not evenly divisible by 6, then the encoder must pad the resulting output with some number of unused bits.

Example:

$echo 'a' | base64
YQ=

ASCII a is 0x61, or 01100001 and requires 8 bits to represent, so we have to use two 6 bit base64 digits to represent it.

ASCII:   |    a    |
binary:  |011000|010000|
base 10: |  24  |  16  |
base 64: |  Y   |   Q  |

The encoder will normally then pad the number of base64 digits out to a multiple of 4 with =s, but ectoken strips those.

That those last 4 bits (in this example) are discarded means that I can do this echo 'YZ==' | base64 -d and still get a.

ASCII:   |    a    |
binary:  |011000|011001|
base 10: |  24  |  25  |
base 64: |  Y   |   Z  |

If you try changing the first character in the token it should fail completely.

I'm going to post my new tests soon, they run very slowly because they basically brute force changing base64 encoded bytes in the token and validate that the decryption fails properly unless the changed bits are in the discarded padding. I'll leave this open until that's merged.

from ectoken.

hattan avatar hattan commented on August 24, 2024

Thanks, @AbhishekTripathi . We'll investigate this issue and provide an update shortly.

from ectoken.

Related Issues (12)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.