Better HN
topnewbestaskshowjobs
Log inSign up

CiPHPerCoder

6,663 karma · joined Feb 25, 2016 (10y ago) · 1,775 submissions

My name is Scott. I do a lot of open source security research, and cryptography.

Previously AWS Cryptography (2019 - 2023).

Unless otherwise stated, my opinions are my own and do not reflect my employer.

https://scottarc.blog/about/

Submissions

comment 10y ago · link · parent

The only effective political solution is to get the common person in on using end-to-end encryption so its ban becomes unpopular.

comment 10y ago · link · parent

Dear UK government,

Good luck with that.

Signed,

An open source software developer outside your jurisdiction

comment 10y ago · link · parent

Why not SipHash? https://www.131002.net/siphash/

comment 10y ago · link · parent

> “It’s perfect. Great work!”

I cringed. It's not perfect, it's at best excellent.

comment 10y ago · link · parent

> Kinda discouraging that everytime I post this lib I am always asked: "there is already imagine, imageXX etc lib out there. why another lib?" I feel like I violated some code of honor or something.

Y'know how people say, "Don't reinvent the wheel?" The emphasis should be on the.

Don't reinvent THE wheel.

Feel free to invent a better wheel.

Better here can mean simpler, which allows users to be more productive. As far as I can tell, you've accomplished this much. So, good job, and thanks for sharing.

1446.

Setting Up Caddy for PHP 7 on Debian Jessie (Automatic HTTPS)(paragonie.com ↗)

1 points · by CiPHPerCoder · 10y ago · discuss

comment 10y ago · link · parent

Yes, I am Scott. And thank you. :)

comment 10y ago · link · parent

I'm the person who published this advisory to oss-sec and a co-author of https://github.com/defuse/php-encryption

I also wrote https://github.com/paragonie/halite which is a PHP library aims to make libsodium incredibly easy for PHP developers to get right.

For systems that need asymmetric crypto and can't install libsodium, I also wrote https://github.com/paragonie/EasyRSA which side-steps a lot of the mistakes developers make. EasyRSA uses defuse for symmetric-key encryption, then encrypts the AES key with RSA.

Writing secure cryptography isn't trivial. Assuming the three projects I just linked to are secure enough to use (all indications point to: they are), there's literally no reason to reinvent the wheel solely for Magento.

Magento already uses Composer; they could just add them to their composer.json file and rewrite their routines to use defuse + maybe EasyRSA if they have a use case for it.

Zend\Crypt is also an acceptable choice, as long as you don't install the version with an RSA implementation vulnerable to padding oracle attacks. https://framework.zend.com/security/advisory/ZF2015-10

comment 10y ago · link · parent

In a previous discussion: https://news.ycombinator.com/item?id=10345965

comment 10y ago · link · parent

Even JSON isn't great. It's still a hash-collision DoS attack vector.

https://paragonie.com/blog/2016/04/securely-implementing-de-...

comment 10y ago · link · parent

Please excuse me if this comes across as anything other than constructive criticism, but I don't believe checklists should be used to guide web developers to build secure software.

My reason for this belief is that, in my experience, it engenders tunnel vision and what I appropriately refer to as a "checklist mentality". There are developers who believe, "We're immune to the items on the OWASP Top 10, so we're secure," when there are entire classes of vulnerabilities that applications can be vulnerable to (say: using a weak and predictable PRNG for their password reset tokens) that isn't adequately described by the OWASP Top 10.

An alternative approach that I feel is more helpful is to organize insecurity into a taxonomy.

  * Code/data confusion
    * SQL Injection
    * Local/Remote File Inclusion
    * Cross-Site Scripting (XSS)
    * LDAP Injection
    * XPath Injection
    * Several memory corruption vulnerabilities
  * Logic Errors
    * Confused deputies
    * CSRF
    * Failure to enforce access controls
  * Operating Environment
    * Using software with known vulnerabilities
    * Using HTTP instead of HTTPS
  * Cryptography flaws
    * Yes, this deserves a category of its own
    * Chosen-plaintext attacks
    * Chosen-ciphertext attacks
    * Side-channel cryptanalysis
    * Hash collision vulnerabilities (e.g. length-extension)
    * Weak/predictable random values
You can further break down into more specific instances.

There are three types of XSS (stored, reflective, DOM-based). There are blind SQL injection techniques worth studying too. But the underlying problem that makes these vulnerabilities possible is simple: User-provided data is being treated as code. Any technology that prevents this confusion will greatly improve security.

For example: SQL injection is neutered by using prepared statements. You might one day forget to manually escape a single input (and it only takes one to be game over), but if user data is always passed separately from the query string (i.e. you never concatenate), there's no opportunity to make this mistake. There were also corner-case escaping bypass attacks (usually involving Unicode) that you might not be vulnerable to. With prepared statements, these clever multibyte character tricks accomplish nothing. The query string is already in the database server before your user's parameters are sent.

I believe teaching developers to think in terms of taxonomy (very general to very specific) will result in a greater understanding of software security and reduce the incidence of vulnerable code.

I've written about this before, in case anyone wants to link to something besides an HN comment: https://paragonie.com/blog/2015/08/gentle-introduction-appli...

---

EDIT: Opened an issue: https://github.com/FallibleInc/security-guide-for-developers...

comment 10y ago · link · parent

This might help: https://paragonie.com/blog/2015/08/you-wouldnt-base64-a-pass...

comment 10y ago · link · parent

A fourth option would be just like option 3, except you only use part of the DB token in the lookup and compare the remainder in constant-time if and only if the record exists (if you're worried about the database lookup leaking a valid authentication token).

Agreed that public key crypto isn't really appropriate here.

1454.

Threat Modeling for Applications(adamcaudill.com ↗)

3 points · by CiPHPerCoder · 10y ago · discuss

comment 10y ago · link · parent

That's simultaneously wrong and misleading.

"The Cloud" isn't a company that has direct access to a certificate authority.

"The Cloud" doesn't produce a valid TLS certificate for YOUR website, to encrypt the connection between them and your visitors, but not necessarily between them and your server.

"The Cloud" is a vague term for "other people's computers".

CloudFlare is better than plaintext HTTP, but if your goal is confidentiality, then CloudFlare is probably worse than direct HTTPS with no intermediaries.

Again, threat models differ. For most people, CloudFlare is probably just fine.

comment 10y ago · link · parent

Please do keep in mind that CloudFlare is essentially a consensual man-in-the-middle and for certain threat models is not compatible with the "secure" modifier.

If your threat model differs, this is cool.

1457.

Setting Up Caddy for PHP 7 on Debian Jessie (Automatic HTTPS)(paragonie.com ↗)

2 points · by CiPHPerCoder · 10y ago · discuss

comment 10y ago · link · parent

We actually have a blog post for this exact question.

https://paragonie.com/blog/2016/04/go-php-7-our-commitment-m...

The short of it:

* PHP 7 allowed us a combination of type safety and brevity that makes it much easier to reason about the security of Halite in a way that PHP 5 does not.

* There is a very bad habit in the PHP community, led by WordPress, to provide very legacy support (i.e. PHP 5.2.4 in 2016). For that reason, we're going against the grain focusing on PHP 7 only. If people want to use any of our new open source libraries, they need to make the decision to upgrade now.

comment 10y ago · link · parent

> The only thing that leaps out at me from the readme, is the lack of a suggested way to store/recover the salt? Ideally I'd see a function that takes a "password" and some "plaintext" - generates a salt from an OS provided source, an IV (if applicable) and returns a package of the cipher-text along with the salt (and IV).

Generally you want to just do this once:

    $key = KeyFactory::generateEncryptionKey();
    KeyFactory::save($key, '/path/outside/webroot');
And from then on:

    $key = KeyFactory::loadEncryptionKey('/path/outside/webroot');
Encryption typically never touches a password (although you can derive one from a password and salt if you so choose). The normal way of doing things is to just use a random key.

(My takeaway is: the README for v3 probably needs work to make this more clear.)

Thanks for the feedback! :)

comment 10y ago · link · parent

Hi HN,

I've been working on this project for a year now, and looking to push for a version 3 release before 2016 is over.

Halite takes a lot of guesswork out of cryptography. You don't even need to know what a nonce is to use it successfully.

I'd like to get more feedback from other developers if possible.

1461.

Show HN: Halite – A simple libsodium wrapper for PHP projects(github.com ↗)

43 points · by CiPHPerCoder · 10y ago · 10 comments

comment 10y ago · link · parent

Stop saying 32 bit, please. It's 32 byte, or 256 bit.

Furthermore, use a KDF to stretch your password into a key suitable for encryption.

comment 10y ago · link · parent

I'd be interested in hearing WhatsApp's response to this.

Or moxie's, for that matter. He's been contacted by the Saudi government before and publicly turned down their offers to be complicit in their human rights violations. (He also wrote the encryption that WhatsApp uses.)

https://moxie.org/blog/saudi-surveillance/

More importantly, can anyone independently verify this? :)

comment 10y ago · link · parent

What are your thoughts about SQRL?

comment 10y ago · link · parent

> The TOTP stuff will never be widly used. Its just a total pain to work with.

I'm not sure I agree with that.

Generating a code:

  <?php
  use ParagonIE\MuiltiFactor\Vendor\GoogleAuth;
  use ParagonIE\MultiFactor\OTP\TOTP;
  
  $seed = random_bytes(20);
  /** Then persist $seed into the database for a user **/
  
  $gauth = new GoogleAuth($seed, new TOTP());
  header("Content-Type: image/png");
  $gauth->makeQRCode();  
Validating a code:

  <?php
  use ParagonIE\MuiltiFactor\Vendor\GoogleAuth;
  use ParagonIE\MultiFactor\OTP\TOTP;
  
  if (\password_verify($_POST['password'], $storedHash)) {
      $seed = /** Get seed from database for this user **/;
      $gauth = new GoogleAuth($seed, new TOTP());
      if ($gauth->validateCode($_POST['2facode'])) {
          // Login successful
      }
  }
Then you can just use the 2FA app of your choice (Authy, Google Authenticator, etc.), scan the QR code, and you're good to go.

comment 10y ago · link · parent

> Displaying the answers to your security questions in multiple choice form (with a none of the above option, but usually including your answer).

Kill it before it lays eggs.

> Requiring your password to be entered with mouse clicks at an on-screen keyboard. Not kidding.

  [x] Bad security
  [x] Bad usability
  (Edit: apparently unicode checkmarks are filtered out on input now)
This is like the personification of a lose-lose interpretation of AviD's rule of usable security.

comment 10y ago · link · parent

It sounds like we should probably all get together and write a draft RFC for this. Choosing a good directory to toss everything into would be grand.

I'd prefer .well-known since there's already an RFC for it, but maybe .dev-extra would be more appropriate?

comment 10y ago · link · parent

Thanks! I'm not sure why I didn't copy/paste. :)

comment 10y ago · link · parent

I worked on an open source CMS called Airship and we decided to include 2FA in our v1.0 release. After a bit of research (mostly to conclusively rule out SMS-based 2FA), I found that it was actually very easy to implement.

I started working on a vendor-agnostic 2FA implementation for PHP projects.

https://github.com/paragonie/multi_factor

It's far from complete, but hopefully it makes it easier for others to add 2FA to their projects.

If anyone's interested in the open source CMS I mentioned: https://github.com/paragonie/airship

1470.

Securing a PHP Application in 2016: The Pocket Guide(paragonie.com ↗)

2 points · by CiPHPerCoder · 10y ago · discuss

1
484950
60