Fork me on GitHub
#off-topic
<
2023-05-15
>
Dimitar Uzunov06:05:13

Has anyone else faced the problem of a too long Content-Security-Policy header? The one I’m maintaining is almost 4096 bytes and more than that can’t fit in the nginx config file without causing errors :)

Dimitar Uzunov08:05:26

dang I was looking if this is possible

Dimitar Uzunov09:05:30

thanks @U04V4KLKC I will try it out

Dimitar Uzunov10:05:08

hmm I’m possibly doing something wrong

Dimitar Uzunov10:05:23

but it seems like only the default-src is read

Dimitar Uzunov10:05:34

turns out that extra headers can only further restrict, this is why I can’t have multiple in effect

delaguardo10:05:56

I'm not sure I follow) could you tell more what are trying to get at the end?

Dimitar Uzunov11:05:41

I have a really big policy (lots of 3rd party content we link to)

Dimitar Uzunov11:05:41

so very soon it will not be able to fit in this nginx config buffer allocations: https://github.com/nginx/nginx/blob/master/src/core/ngx_conf_file.c#L11

Dimitar Uzunov11:05:42

what you suggested could have worked if it was all in the same default-src fetch directive

Dimitar Uzunov11:05:17

I could be doing something wrong, but what I see is the extra policies I’ve set are ignored and it is falling back to default-src:

Dimitar Uzunov11:05:46

I get errors like ” Note that ‘font-src’ was not explicitly set, so ‘default-src’ is used as a fallback.”

delaguardo11:05:54

is the origin of font file the same as the origin of response? self means: allow if the font is loaded from the same host as the page itself.

Dimitar Uzunov11:05:27

there are further origins I specify afterwards

Dimitar Uzunov11:05:49

it seems to not see any of the policy as it says its not explicitly set

Dimitar Uzunov11:05:53

yeah probably self should be removed, but it hasn’t caused us issues so far

delaguardo11:05:15

I don't have enough experience configuring CSP headers, sorry

Stuart16:05:35

Didn't know what pairwise co prime meant so asked chat gpt, it gave me an answer that I thought I understood... Turns out I did understand it but my code had small bug. So I asked it if 3 5 7 and 8 were pair wise coprime (my buggy code was saying no...) Here's it's reply.. I was, at least momentarily, very confused!

p-himik16:05:53

After seeing so many posts like this one and also trying it for a bit myself only to see it fail spectacularly, I'm sticking to Wiki and random blog posts for the time being.

💯 11
selahb13:05:41

As that 3.5 or 4? 4 seems to be quite a bit more reliable:

selahb13:05:04

Even better with plugins!

p-himik13:05:42

Now try asking it what the correct RegEx for parsing emails is. :) But this already might be in the zeitgeist, not sure.

selahb14:05:41

Pretty good response

selahb14:05:22

If 5 is to 4 as 4 is to 3, we may all be able to pack up and enjoy our obsolescence.

Stuart14:05:25

How do you know if it's 3.5 or 4. I just go to openai and click try chatgpt

selahb14:05:14

You have to use the pro feature or the API and request access to 4. It's quite a bit slower, but much smarter.

p-himik14:05:40

@U066ZAMBJ "For most practical purposes" - that's what I'm talking about. It cannot come up with a correct and complete answer. At the very least, there are quite a few characters that should be allowed that that RegEx doesn't let through (assuming, I myself read that RFC correctly). And I wouldn't be surprised if the RegEx lets through some stuff that shouldn't be. "It's a trade-off" - yeah, nah. It's a trade-off if you have to think come up with a RegEx yourself. It's not a trade-off when there already is a solution in the form of some library.

p-himik14:05:17

Not entirely related, but I recently got bitten by it - because, while the main Apple account accepts + in email addresses just fine, some specific services do not. Wasn't fun to work around that one.

Ludger Solbach19:05:47

GPT is still a language model and not a knowledge model. It creates text in the first place, not neccessarly correct text. ;-)

1