19

Take the following update:

The OP suggested security through obscurity and the editor amended the answer to remove the OP's update. Now, I agree with the editor that this is a bad practice but I'm unsure whether their action was the correct one.

In these scenarios isn't the norm to leave a comment/show your disapproval through voting rather than amending the OP's answer to suit what you want, irrespective of the validity of the edit in a technical sense, or, is what the editor did fine?

10
  • 4
    I don't see why this particular case is "security through obscurity" as it clearly states "Base64 ...and then encrypting …" (converting bytes to Base64 and then again back to bytes for encryption does not sound … ideal … but definitely not insecure). Commented Mar 25, 2019 at 14:03
  • 1
    @AlexeiLevenkov because the OP is suggesting to encode the data purely to prevent people from being able to see it in its original form thus making it trivially harder to edit, it was in a question to do with preventing XSS / other attacks therefore this method would definitely be seen as "security through obscurity".
    – Script47
    Commented Mar 25, 2019 at 14:06
  • 1
    @AlexeiLevenkov is right: obscurity isn't the point; defeating SQL injection is the point. Base64 can't contain quote characters. (en.wikipedia.org/wiki/Base64#Base64_table). Encrypting seems pointless, but Base64 will work (at the expense of making indexing / searching on that field not usable). It's not a terrible idea for defending against 2nd-order and lateral SQL injection, when a later query (perhaps manually done by a DB admin) uses data from the DB as part of a query. Commented Mar 25, 2019 at 21:12
  • 2
    It seems like an ugly / inefficient solution, but worth considering if you don't trust other code or people who do queries on the database to always remember that data coming from the DB could still be malicious. Commented Mar 25, 2019 at 21:14
  • @PeterCordes with respect, I believe you have misunderstood the context. The question is asking about security, however the base64 method is security through obscurity i.e. encoding all the data so it is unreadable to a novice, I'm confident that any script kiddie worth their weight would know to that it is base64 and would then decode it trivially. The point of the editor to remove this specific paragraph was because security through obscurity is not a good principle to rely on when you have so many more sure fire ways to prevent XSS or SQL injection.
    – Script47
    Commented Mar 25, 2019 at 21:26
  • Truth be told, some basic validation to ensure the input you are receiving is what you are expecting alongside prepared statements and on output using htmlspecialchars should solve majority of your issues.
    – Script47
    Commented Mar 25, 2019 at 21:28
  • 1
    The original tags on the question included [sql-injection]; only a day later did the OP add [xss]. The answer never explains the purpose of base64 encoding. It seems obvious to me that it's potentially useful as a way of storing arbitrary data in a DB without ever sending anything but plain text through SQL queries, not for defending against people stealing your database. And like I said, getting "nasty" data safely into your database with a prepared statement isn't always sufficient: 2nd-order SQL injection can attack unsafe interactive use of that data. Commented Mar 25, 2019 at 21:49
  • 2
    This is kind of a belt-and-suspenders approach which is unnecessary if all your code is safe, and your DB admins don't build queries out of data from the DB. Even if that's the case, an extra layer of obscurity doesn't actively hurt. Just be sure not to rely on it as your primary defence. The security-through-obscurity argument isn't that every form of obscurity is bad, just that obscurity is not sufficient. (And that inventing your own unpublished cryptosystems is a terrible idea.) But I don't think the post was claiming that this is anything more than an extra layer vs. SQL injection. Commented Mar 25, 2019 at 21:51
  • 1
    @PeterCordes Regarding this particular case, that "extra layer" probably not provide extra security, but it unnecessarily bloats the data size. Definitely not a good practice.
    – user202729
    Commented Mar 26, 2019 at 14:40
  • 1
    @user202729: Yeah, I would not recommend it in general. But I think it's worth considering if you're very paranoid about 2nd-order SQL injection, and that outweighs performance / size. Commented Mar 26, 2019 at 20:03

1 Answer 1

36

If you disagree with an answer's contents, downvote that answer.
You can also add a comment explaining what's wrong.

You don't edit the answer to remove the part you disagree with. That's a sure-fire way to get into an edit war.

Same goes for adding new content to answers. It's better to write a new answer and let that get voted on.

8
  • Should this edit be left as is or should it be rolled back, or would that then cause a rollback war?
    – Script47
    Commented Mar 25, 2019 at 14:02
  • 8
    Rolled back, absolutely. If the editor re-applies the edit, flag the answer so a moderator can intervene.
    – Cerbrus
    Commented Mar 25, 2019 at 14:03
  • Rolled back with a comment pointing here. Thanks.
    – Script47
    Commented Mar 25, 2019 at 14:17
  • Except that people are scared to downvote because they lose rep
    – Alec
    Commented Mar 26, 2019 at 21:26
  • 1
    @alec935 People shouldn't worry about that one rep lost on a downvote. It's insignificant.
    – Cerbrus
    Commented Mar 26, 2019 at 21:27
  • 1
    If it’s insignificant SO should remove it. You can’t have it both ways.
    – Alec
    Commented Mar 26, 2019 at 21:28
  • I thought that adding new content to answers to improve them was encouraged. Did that change?
    – Mike Brind
    Commented Mar 26, 2019 at 21:38
  • 3
    There's a difference between improving an answer and completely changing what it says, @Mike. If you leave the meaning of the answer intact, you're fine. This case, however, completely removes an opinion / option / explanation from an answer. That was never okay.
    – Cerbrus
    Commented Mar 26, 2019 at 21:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .