In general, answers that are factually and technically incorrect should be handled by the community without moderator intervention. Moderators have a custom flag decline reason that reads "flags should not be used to indicate technical inaccuracies, or an altogether wrong answer". There are a few options on what to do. Minimally, a comment should be left explaining why the answer is inaccurate or wrong and the answer should be down voted. If someone has the time, a correct answer should be posted (and it would be OK to link to that answer in the comment).
However, as software engineers, we also have ethical obligations. You can look at any of the leading ethical codes for computing professionals - the ACM Code of Ethics and Professional Conduct, the Software Engineering Code of Ethics and Professional Practice (jointly created by the ACM and IEEE Computer Society), and the IEEE Code of Ethics. On a community of software engineers, we should remove posts that advocate for conduct that is unethical.
In this particular case, it appears that you and others believe that this answer is unsafe and unsecure. All of the codes of ethics that I linked to above call out considering security and privacy in some way or another:
- Principle 2.9 of the ACM Code of Ethics states that software engineers have a responsibility to "design and implement systems that are robustly and usably secure". Principle 1.1 is more broad and the descriptive text states that "an essential aim of computing professionals is to minimize negative consequences of computing, including threats to ... personal security, and privacy".
- The IEEE Code of Ethics states that members of the IEEE shall "hold paramount the safety, health, and welfare of the public, to strive to comply with ethical design and sustainable development practices, and to disclose promptly factors that might endanger the public..." and "avoid injuring others, their property, reputation, or employment by false or malicious action". Although it is only enforceable toward IEEE members, it is a useful consideration as to what ethical behavior of engineers should look like.
- The ACM/IEEE-CS Software Engineering Code of Ethics and Professional Practice states that software engineers should "approve software only if they have a well-founded belief that it is safe, meets specifications, passes appropriate tests, and does not diminish quality of life, diminish privacy or harm the environment."
I'm going to reiterate: Any question or answer that promotes conduct that can be considered to be unethical by multiple prominent professional codes of ethics for computing professionals or software engineers has no place here and should be removed. If anyone sees a post that they believe promotes unethical or unprofessional conduct, please raise a post here on Meta. Moderators see notifications of all new Meta discussions. Also link to the Meta discussion on the post itself in a comment with a brief description of what the problem is so people can be aware of it.
I reviewed this particular question and answer.
I observed that the answer does not actually answer the question asked. Instead, it gives an implementation to do the type of thing being asked about. As pointed out in some of the comments, the code also doesn't work out of the box.
It does appear to be unsafe code and the answer does not highlight potential problems with using this approach. It does not refer to accepted or known good practices. Given the number of up votes and the accepted state, a user with insufficient knowledge about security may be given the false impression that this is a good solution to a problem unless they read the comments.
I don't believe that this answer meets the standards that we should be upholding, so I have deleted the answer.