Giter Club home page Giter Club logo

Comments (9)

5HT avatar 5HT commented on May 16, 2024

Please use {n2o,[{pickler,n2o_secure}]} in sys.config for enabling AES-CBC/RIPEMD pickling.
By default N2O uses transparent proxy model.

from n2o.

benmmurphy avatar benmmurphy commented on May 16, 2024

Thanks :) I missed this.

Looking at the crypto it seems to be broken.

https://github.com/5HT/n2o/blob/c57e01a594780e3ebd684a763d1da871e2604c2e/src/handlers/n2o_secret.erl#L20

  1. you use crypto:hash with a MD hash function with the secret as the prefix. this allows for hash extension attacks. (http://en.wikipedia.org/wiki/Length_extension_attack). This allows an attacker to add arbitrary encrypted blocks to the end of the message and it will still verify.

  2. you have the IV specified in the message and don't calculate the MAC over the IV. CBC decryption of the first block is done by: P0 = D(C0) xor IV. The attacker is able to supply an arbitrary IV of their choice. So if attacker knows P0 (likely because we are using fixed message formats) then the attacker can set IV' = IV xor P0 xor P0' then you will calculate.

D(C0) xor IV'
= (IV xor P0) xor (IV xor P0 xor P0')
= P0'

So attacker is able to set the first block of the cipher to a P0' one of their choice. I don't think this is enough for RCE but you should be able to DoS the server by flooding the atom table. You can see this attack here: http://imgur.com/a/m2uhJ#0

from n2o.

wizzard0 avatar wizzard0 commented on May 16, 2024

@benmmurphy see #64 - does that seem correct now?

from n2o.

benmmurphy avatar benmmurphy commented on May 16, 2024

you should use crypto:hmac instead of crypto:hash

from n2o.

wizzard0 avatar wizzard0 commented on May 16, 2024

Hmm that makes sense. @5HT can you do that?

from n2o.

5HT avatar 5HT commented on May 16, 2024

I did change to hmac. I want to thank you @benmmurphy for your effort to make n2o better.
As for atom table flooding I made [safe] binary_to_term depickling.
Now it looks like:

Signature = crypto:hmac(sha256,Key,<<Cipher/binary,IV/binary,Key/binary>>),
{D,_T} = binary_to_term(crypto:block_decrypt(aes_cbc128,Key,IV,Cipher),[safe]),

Also would be good to check the calling module is in application modules (app.src) in n2o_bullet.

Thanks for contributing.

from n2o.

5HT avatar 5HT commented on May 16, 2024

I'm closing if everything is ok now?

from n2o.

benmmurphy avatar benmmurphy commented on May 16, 2024

looks good. you shouldn't need to add Key at the end of the hmac signature but i don't think it effects the security of the construct.

Signature = crypto:hmac(sha256,Key,<<Cipher/binary,IV/binary,Key/binary>>),
Signature = crypto:hmac(sha256,Key,<<Cipher/binary,IV/binary>>),

from n2o.

5HT avatar 5HT commented on May 16, 2024

Thanks again :)

from n2o.

Related Issues (20)

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.