Latest News: 37वें अंतर्राष्ट्रीय जीवविज्ञान ओलम्पियाड 2026 में भारत को एक स्वर्ण और तीन रजत पदक * राष्ट्रीय रक्षा अकादमी एवं नौसेना अकादमी परीक्षा (II), 2025 के अंतिम परिणाम घोषित * सिविल सेवा परीक्षा, 2025 के अंतिम परिणाम घोषित

When deleted articles return, a website security lesson...

A seemingly routine day of website management turned into an unexpected technical investigation when hundreds of previously removed stories suddenly reappeared in the Content Management System, i.e. CMS, of a news website. The incident raised an important question: how could articles that had been removed from the database return without anyone deliberately restoring them?

The initial suspicion was that something had gone wrong with the database, the CMS, or perhaps the website's content management process. However, a closer examination of the website's PHP code and database operations revealed a more specific explanation. An old article migration utility, originally developed to transfer historical content from an open-source CMS Platform to a CodeIgniter-based news website, had remained accessible through a public web address. The investigation eventually identified this obsolete migration functionality as the likely source of the problem.

The problem first became noticeable when previously deleted stories started appearing again in the website's CMS. These were not newly submitted articles or content restored manually by an administrator. They were historical stories that had existed on the website before and had already been removed from the active content database.

The unusual nature of the incident made it necessary to investigate beyond the normal CMS editing and publishing process. Simply deleting the visible stories again would not have addressed the underlying problem. If an automated process brought them back, the same incident could happen repeatedly. The investigation therefore focused on identifying the mechanism through which old articles were being inserted into the database.

The website's backend was built using PHP and the CodeIgniter framework, with MySQL serving as the database system. During an earlier migration, a dedicated controller named 'Cron_job' had been developed to facilitate the transfer of content from an older Open Source CMS installation.

The controller contained several functions designed to perform different maintenance and migration operations. These included importing categories, transferring historical articles, processing article images, creating file records and updating sorting orders.

One of its functions, named 'article()', was particularly important. Its original purpose was to retrieve historical articles from the Open Source CMS database and insert them into the new website's 'news' table. The function retrieved the source articles through a database model method called 'GetJosArticle()', processed the records one by one, and inserted them into the destination database using 'InsertArticle()'.

This functionality was useful during the original migration. However, the problem was that the migration controller had not been adequately restricted after its original purpose had been fulfilled.

In CodeIgniter, public controller methods can generally be accessed through their corresponding URLs. Consequently, the article migration function could be invoked through an address similar to 'XYZ.com/index.php/cron_job/article'. This meant that the migration functionality was potentially accessible to anyone who could make a web request to that address, without requiring access to the website's administrative dashboard. The old migration utility had effectively remained an operational part of the website even though its original purpose had ended.

A closer examination of the original PHP function helped explain how the deleted stories could have returned. The migration process retrieved records from the old Open Source CMS database, reversed their order and then processed them through a loop. For each article, it collected information such as the title, category, introduction, description, publication status, creation date, metadata and original URL alias. The script then generated a corresponding website URL and inserted the article into the new database.

An important part of the original code was its sorting operation. Before inserting each article, the function called 'UpdateAllAddSortorderArticle()' and assigned a sorting value of '1' to the new record.

The relevant operation was:

'$record['sortOrder'] = 1;'

The script subsequently called:

'$this->Cron_model->InsertArticle($record);'

This provided an important clue during the investigation because the returned deleted records were also found with 'sortOrder = 1'.

The original migration function did not have an adequate independent duplicate-protection mechanism to prevent the same deleted articles from being inserted again. Therefore, another execution of the migration process could potentially create additional records even when the articles had already existed in the destination database. The evidence was consistent with the old migration function having been executed again.

One possible explanation was that an automated web crawler or bot had accessed the publicly available migration URL. Automated crawlers regularly visit websites to discover pages, follow links and examine publicly accessible URLs. If a migration endpoint is exposed on a website, it may be requested by an automated system if discovered or otherwise identified.

Another possibility was that the URL had been accessed during manual testing or website maintenance. An existing scheduled task or another automated process could also have invoked the controller.

Server access logs and cron-job records would be needed to conclusively determine whether the execution originated from an automated crawler, manual testing or another scheduled process.

Nevertheless, the investigation identified the publicly accessible migration functionality as the principal security weakness that needed to be corrected.

Once the problem had been traced to the old migration utility, the next priority was to prevent it from being executed through ordinary web requests.

Rather than deleting the entire 'Cron_job.php' controller, a more controlled approach was adopted. The controller contained several other maintenance functions that could still be useful for future technical work.

The solution was to restrict the entire controller to command-line execution. A security check was introduced into its constructor using CodeIgniter's built-in CLI request detection method:

if (!$this->input->is_cli_request()) {

    show_404();

    exit;

}

This small but important change meant that requests originating from a normal web browser would be rejected before any controller function could execute.

As a result, URLs such as the following would no longer trigger their respective operations through public web access:

- '/index.php/cron_job/article'

- '/index.php/cron_job/category'

- '/index.php/cron_job/imageChange'

- '/index.php/cron_job/imagetofile'

- '/index.php/cron_job/updateSortorder'

The migration controller was retained, but its browser-based accessibility was removed.

This approach also preserved the possibility of running necessary maintenance functions through PHP command-line execution, subject to the security of the hosting account and command-execution environment.

Restricting public access was only one part of the solution. Since the deleted article migration had already been completed and was no longer required for routine website operations, the old 'article()' function was also disabled by commenting out its complete implementation. This provided an additional safeguard.

Even if the controller were deliberately executed through the command line in the future, the disabled article import function would no longer be available for execution.

The remaining maintenance functions were preserved so that they could be used when necessary, but they were no longer accessible through public web URLs.

After addressing the migration controller, attention turned to the database records that had unexpectedly returned.

The investigation identified 'sortOrder = 1' as a useful indicator of the imported records. However, sorting values alone should not automatically be treated as proof that every matching record is unwanted.

The appropriate procedure is to identify the affected records, verify them against their deleted content and import characteristics, and then remove only the unwanted entries.

A preliminary database check can be performed using:

SELECT *

FROM `news`

WHERE `sortOrder` = 1;

Once the affected records have been verified, the corresponding unwanted entries can be deleted. This distinction is important because database cleanup must not accidentally remove legitimate news stories that may share the same sorting value.

The incident highlights a security weakness that can easily be overlooked during website development and maintenance: temporary migration scripts and maintenance controllers can remain operational long after their original purpose has ended.

A script developed to solve a legitimate technical requirement can eventually become an unintended entry point if its accessibility is not reviewed.

There are several important lessons from this experience.

First, migration scripts should never remain publicly accessible. Database import, export, deletion and bulk-update operations should be restricted to authorised administrative or command-line environments.

Second, obsolete functionality should be disabled. Once a migration has been completed, its execution mechanism should be removed or securely restricted. Keeping old code for future reference is reasonable, but leaving it accessible through a public URL is not.

Third, duplicate protection should be built into import operations. A migration process should verify whether a source record has already been transferred before inserting it again. Maintaining the original source identifier in the destination database can make this process considerably more reliable.

Fourth, database operations should be monitored. Unexpected increases in record counts, repeated imports and unusual changes in content sorting can provide early indications of unintended activity.

Finally, server access logs and scheduled-task configurations should be reviewed whenever an unexplained database operation occurs. Identifying the exact trigger is as important as correcting the vulnerable functionality.

This type of incident demonstrates how even a relatively small oversight in backend development can create unexpected consequences for a live website. A migration script that was once useful for transferring historical content can become a potential security weakness when its execution is not properly controlled.

The broader lesson is equally important: website security is not limited to protecting login pages, administrative dashboards and user accounts. It also requires regularly reviewing the scripts, controllers, scheduled tasks and database operations that operate behind the scenes.

In a dynamic publishing environment, maintaining a secure website means not only protecting the content that is currently being published but also ensuring that old tools cannot unexpectedly bring back content that was deliberately removed.