5 ms·
It could help in obvious cases, but it sounds a lot like "security by obscurity".
by amelius 10y ago
It could help in obvious cases, but it sounds a lot like "security by obscurity".
- TillE 10y agoRight, it does nothing to protect from targeted DoS attacks. The obvious answer is that you usually want a fixed-size buffer per connection, and any message larger than that needs to be read and handled chunk by chunk.
- pdpi 10y agoNo, it's just a bit of defensive programming against silliness and misconfiguration. Not every errant connection is an attacker trying to pwn you, some are just going to be honest mistakes. Picking up on wrong magic numbers and logging "missing magic from <ip>" would help immensely debugging this issue. All the other advice about avoiding mallocing an unsanitised amount of memory still stands, but this would just make it all easier to figure out
- deleted 10y ago[deleted]
- phamilton 10y agoMost database drivers have a binary protocol that does this. It's a pretty standard practice. It's not for security, it's for protocol negotiation.
- jlarocco 10y agoI disagree. It's a well known method of sanity checking serialized data, and it's used by lots and lots of file formats and "over the wire" data formats. It's not really a security feature, and it doesn't have to be a secret value. It also doesn't mean you shouldn't sanity check the other data fields. The sole purpose is to quickly rule out data that's blatantly incorrect.