With the arrival of AI in IT and programming in general, the market has changed significantly. We mean not the software development market itself, but in general, the connections between businesses have changed. Many companies decided that AI could give a push to their business development and made a bet on this technology. As it turned out later, not everyone was 100% sure about the correctness of this decision; moreover, not everyone used such a powerful tool correctly.

At the end of 2024, one of our acquaintances, who was doing business in the agricultural sector, contacted us. For more than 10 years, the feature of his business was a symbiosis of scientific agriculture and modern IT technologies. In general, this allowed him to save about 8-10% of the budget on various optimizations (building better logistics routes for his fleet, tracking vehicle maintenance, tracking crop purchases from small farmers for resale, etc.). Usually, his model was built like this: specific changes, improvements, and bug fixes were made to the already working system. Usually, this was done by small teams or ordinary freelancers found on freelance marketplaces.

Just two months ago, one of these improvements was made: a function to scan QR codes on boxes was introduced for the automatic tracking of purchased corn. In general, the system worked like this: regular sellers (usually small farmers) unloaded their corn into special pallets, pasted a QR code on them, and the receiver at the warehouse scanned it. The product data was automatically entered into a table, and at the end of the season, a detailed calculation and automatic money transfer to a bank account were made. In general, everything was transparent and simple. However, there was one moment: for registration in this system, someone made the decision to use SMS codes. The system was modified, tested, and put into production mode.

Returning to the main point: 2 months after its integration, our acquaintance contacted us with a request to check why he was receiving bills for SMS messages of more than $2,000 per month, even though, according to analytics, there were barely more than 20 connected clients. Definitely, something did not add up.

We took his Android application for a review and decided, first of all, to check exactly what modifications were made to integrate this functionality. From a product perspective, everything was done correctly: the separation of business logic and platform logic was present, any tests were absent (seeing this was already a norm for us), and the interface was beautiful.

Also, one of the important points in the conversation was that our client mentioned that the person from whom he ordered the modification actively used AI. This partially covered his lack of experience, or rather, the complete absence of experience: he claimed that a 2-month developer course and AI assistants were completely enough. In addition, he asked for a price almost 3 times lower than the market average. Well, this was not something strange: by that time, many people were already actively integrating AI into their processes. However, we still decided to check the whole application from a security perspective. And there was something interesting there.

First of all, we found the key for registration API calls directly in the build.gradle file. In general, it got directly into the final APK file in an unchanged form. But we understood that the key itself was not enough to call the authorization method millions of times. So, there was something else.

We went to search for open data on Dev and Stage environments. And yes, the Swagger of the Dev environment was practically in open access, covered by authorization with login=admin and pass=admin. In theory, this was already enough to call the authorization method as many times as wanted, if there were no limitations on the backend or on the client. Further verification of the Android application showed that neither a captcha nor a client-side limitation in the form of sending device ID, location, etc., was implemented. The backend code research also did not show the implementation of any systems to counter fraud attacks.

We decided to divide the rescue plan into three stages: urgent, medium-term, and long-term. First of all, we simply disabled registration from other countries in the SMS provider's personal account. There was no need for this, because the entire business was limited exclusively to the adjacent territory. We also set a limit on the daily budget for SMS messages. Even these minimal actions already cut 99% of all expenses, because SMS were rarely sent from the client's country.

We made an immediate MR with the changed API key and released a mandatory update for all clients, because we planned to close all endpoints that worked with the old key. There was nothing strange in this, because the number of clients did not exceed 30, and we could simply call everyone by phone in case of need and as a last resort. We also covered Swagger with normal authorization.

The main step was the modification of the backend. We integrated a mandatory captcha for authorization on it and made a call limit of 3 times per hour from one phone number. We also modified the Android application so that the IP address, device ID, and additional metadata were sent in the method. This way, we strictly tied the device to the request session in the backend.

The fraud attack stopped, and our friend was calculating the losses. In general, he saved about $400 on the development of the new functionality, but at the end of the month, he had a bill of $2124 for SMS messages. There were rumors that he disputed this with the SMS provider; we do not know how it ended, but a joke about "Golden AI Corn" appeared in our bureau, especially considering that only 7 kg of it was purchased for the whole season. A bad harvest year.