Live data from Hacker News

Password protect a static HTML page

github.com

101–110 of 294 posts

Re: Password protect a static HTML page

#101
post #74

Earlier quoted context omitted.

I don't know what "being a stream" has to do with anything (you should virtually always use "stream" modes of AES); the meaningful distinction between CBC and GCM is that GCM authenticates the ciphertext, so you can't tamper with it.

> so you can't tamper with it. ... if the API provided is correctly designed, and either the language made it practical to design the API in a misuse-resistant way /or/ the programmer was actually careful and used it properly. We both know it's way more likely the problem in your actual system is "Oops, we use the bogus plaintext here despite the validation error" than "Dastardly enemy cryptographers have made a brea…

I'm not thinking very hard about it; there is just never a reason to use unauthenticated encryption modes. When I wrote that comment, I hadn't even looked to see if they'd manually authenticated their ciphertext (spoiler alert: you can guess).

Re: Password protect a static HTML page

#102
Oh neat, this is a neat concept. Always wanted a secure way to password protect a page without server side coding, and this is definitely the closest we've gotten in years.

Not sure I'd trust it myself, but it definitely seems like a good option for those with limited hosting options (like GitHub pages or Neocities) and a need to secure some content.

Re: Password protect a static HTML page

#103
post #90

Earlier quoted context omitted.

You keep saying "the Galois Field" as if that was a thing. It's GCM. The components of GCM are CTR mode and the GMAC authentication code, which is based on GHASH. If you're afraid of Galois fields, you don't get to use AES at all! Nobody should be implementing any of these primitives themselves, very much including CBC, which, as you saw downthread, left both you and the author of this project with an insecure crypto…

> You keep saying "the Galois Field" as if that was a thing You're kidding, right? You've never looked at how GCM-mode works? The entire set of math is inside of the GF(2^128) field. That's why its called a Galois Counter Mode. I don't think anyone should be implementing their own GCM mode. Its very subtle and potentially full of traps. CBC on the other hand is pretty dumb and simple, and surprisingly secure and robu…

I think some of my comment went over your head.

Re: Password protect a static HTML page

#104

Earlier quoted context omitted.

> Or... you can have a more nuanced viewpoint The nuanced viewpoint is never implement your own cryptography. > Its so stupid simple I don't think that even a novice would make a critical error. Ask Microsoft about that one: https://learn.microsoft.com/en-us/security-updates/securityb...

That's a Padding Oracle vulnerability, not a CBC error.

Padding is an important part of CBC.

Re: Password protect a static HTML page

#105

Earlier quoted context omitted.

> Or... you can have a more nuanced viewpoint The nuanced viewpoint is never implement your own cryptography. > Its so stupid simple I don't think that even a novice would make a critical error. Ask Microsoft about that one: https://learn.microsoft.com/en-us/security-updates/securityb...

That's a Padding Oracle vulnerability, not a CBC error.

It's a CBC padding oracle, intrinsic to the operation of CBC --- if you PKCS7-pad some other mode, you do not get the same attack --- the single best-known cryptographic vulnerability on the Internet, and the parent commenter took the time to give you the most famous instance of it. For the record: that's also not the only CBC vulnerability.

Re: Password protect a static HTML page

#106
post #89

A more lightweight solution would be to hash the password and have a copy of that file at this url. windows.location = hash(password);

A more lightweight solution would be to let the Webserver (nginx, https, whatever) password-protect the site. No JavaScript required a d highly efficient

Requiring some sort of VM or container to run this webserver on? Is it possible that's way more onerous than a static html file which can be emailed around? Are you sure nginx is even going to be around in, say, 15 years? (think password protected PDF but in html and allowing for JavaScript.)

Re: Password protect a static HTML page

#107
post #91

Pagecrypt does the same thing, but with the Web Crypto API. More (including a sample repo) at https://render.com/blog/static-site-auth-pagecrypt .

Similar here: https://github.com/sowbug/quaid

It works with a GPG-encrypted file. I figured that was safer than developing my own encryption format. As it is, any vulnerability in the decryption process is equivalent to a vulnerability in GPG.

Re: Password protect a static HTML page

#108

I'm not a cryptographer, but I'm pretty sure that CBC ( https://github.com/robinmoisson/staticrypt/blob/main/lib/cry... ) should be replaced with GCM ( https://developer.mozilla.org/en-US/docs/Web/API/SubtleCrypt... ) since this is not a stream. https://security.stackexchange.com/questions/184305/why-woul... (also, use the built-in WebCrypto API instead of the crypto-js package)

The readme links to this issue wrt that decision https://github.com/robinmoisson/staticrypt/issues/19

It seems that the hmac validation makes the GCM unnecessary in their thread model

Re: Password protect a static HTML page

#110
post #10

Earlier quoted context omitted.

I would call any server side or client side code which alters the HTML non-static. A static HTML page is just an HTML file which is stored on the server and displayed as-is in the browser.

Exactly. I don't know where the confusion is, but I'm saying that it doesn't matter how the page is generated. It is sent to the website visitor as just HTML. When the user views it it is all there, just html. No changes. For example, I have a perl script that generates a set of .html files every night to show new additions to my library. They are static .html files on disk and never modified before the user views th…

Everyone is allowed to give their own meaning to words, but you can't expect to just change a widely agreed meaning to match it. "Static" means it is just a set of files. Not that the page is stationary. Do you think that a blink tag in a HTML page makes it non-static? A hover effect? An :after pseudoelement in CSS?

If your perl script is saving the HTML to the disk, then yeah, your website is static. If it's generating HTML on the fly, it's dynamic. That's the widely agreed upon meaning, and that's it.

Post reply on HN