The Daily WTF
Follow
CodeSOD: Authorized Logger
Gretchen's development team was acquired by Initech as part of a company purchase. Initech was interested in their successful software products and their development talent. Initially, Gretchen's team was successful, being given autonomy over projects. They could reuse existing code or rewrite it and choose their own tools, leading to positive outcomes. However, Gretchen was later assigned to a troubled project characterized by constant "firefighting." The project's codebase exhibited poor practices, such as inadequate null handling.The application was constrained to an outdated version of NodeJS, which was no longer receiving updates. Gretchen noted a lack of consistent coding conventions and absent logging. Even the existing logging mechanism was ineffective, only printing the word "DEBUG" regardless of the message content. The code handled HTTP requests by inserting the request body directly into the database without validation. This particular function demonstrated indecision by attempting two different methods for copying request data.Furthermore, the system relied on direct SQL queries in many areas, creating significant SQL injection vulnerabilities. The code also lacked crucial authorization checks, with most endpoints completely unprotected. Even critical endpoints like the admin API had duplicate versions without any authentication configured. This situation highlighted a severe deficiency in security and code quality within the project.