Perl Scripts ·

How to Keep an Old CGI Application Safe Until You Move It

By Manu Mathew, Technical Lead Engineer · Published 25 October 2026 · Last updated 25 October 2026

Somewhere in your business there may be an old CGI application that still does real work. It takes orders, produces reports or runs an internal tool, and it has done so for years. Everyone agrees it should be replaced one day, but that day keeps moving.

In the meantime it still faces the internet, still holds data and still needs to work on Monday morning. This post covers how to keep an old CGI application safe and running while you plan its move, and how to make that move in stages rather than in one risky jump.

Quick answer

To keep an old CGI application safe while you plan its move, first list what it does and where it runs. Then reduce exposure: limit who can reach it, keep the server patched, run it with minimal permissions and take tested backups. Add basic monitoring, and move it to a modern setup in small stages.

What is a CGI application, and why does age matter?

A CGI application is a program the web server starts fresh for every request, passing the request details in environment variables.

The Common Gateway Interface is a simple, long-standing standard, written up in RFC 3875. Many Perl web applications from the late 1990s and 2000s were built this way, and plenty still run today.

Age itself isn’t the problem. The risks come from what tends to surround an old application:

The CGI model also exposes the environment more directly. The Shellshock bug in 2014 was a reminder: on affected servers, a crafted request could reach the system shell through those environment variables.

What should you check first on an old CGI application?

Start by writing down what the application does, who uses it and what it runs on, before changing anything.

I usually record:

This list often turns up scripts that nobody uses any more. Removing or blocking those is one of the quickest ways to reduce risk.

How can you make an old CGI application safer today?

Shrink what an attacker can reach, keep the platform patched and make sure you can recover quickly.

None of these steps needs a rewrite:

  1. Limit access. If only staff use it, put it behind a VPN, an IP allow-list or an extra login at the web server.
  2. Remove unused scripts. Delete them, or block them in the web server configuration.
  3. Patch what you can. Apply operating system and web server updates, even if Perl itself stays where it is for now.
  4. Run with minimal permissions. The scripts should run as a user that can read and write only what they need.
  5. Check how input is used. Look for user input passed to the shell, file paths or database queries without checks. Perl’s taint mode, described in perlsec, can help find these.
  6. Take backups and test a restore. A backup you have never restored is only a hope.
  7. Add basic monitoring. Watch error logs, disk space and unusual traffic, so problems show up early.

Here is how the main protections compare:

ProtectionEffortWhat it reduces
Limit accessLowWho can reach the application at all
Remove unused scriptsLowForgotten entry points
Patch the platformLow to mediumKnown server and system flaws
Minimal permissionsMediumDamage if a script is misused
Review input handlingMediumInjection into the shell, files or database
Tested backupsLow to mediumTime to recover after a failure

Should you rewrite a CGI application or move it in stages?

For most working applications, moving in stages is safer than a full rewrite, because the business keeps running throughout.

A full rewrite asks you to rebuild years of behaviour at once, much of it undocumented. A staged move keeps the old code doing its job while pieces move across one at a time. My post on whether to maintain or rewrite a Perl application covers that decision in more detail.

Document cards pass through an arch from an old charcoal server to a newer blue-topped one, with stepping tiles

How do you move a CGI application to a modern setup in stages?

Wrap the existing code so it runs under a modern setup first, then replace parts one at a time behind the same web addresses.

A typical order of work looks like this:

  1. Build a safety net. Record sample requests and responses, and add tests around the important paths. This can be done without changing the code first.
  2. Run the old scripts under a modern setup. Often the existing code can run largely unchanged under a modern Perl framework, which brings better logging, testing and deployment.
  3. Move to a supported platform. A newer operating system and Perl, sometimes in a container. Keep the old platform running until the new one is proven.
  4. Replace one area at a time. Rewrite a single section, route its web addresses to the new code and compare results with the old version.
  5. Retire the old pieces. Once a section has run well for a while, remove its old script.

Each step is small enough to test and, if needed, undo.

How do I work with a team on an old CGI application?

I begin with a read-only review, agree the quick safety fixes, and then plan the staged move in writing with clear checkpoints.

Whether you’re looking for a Perl developer in India, a Perl developer in Kerala or someone nearer to you, ask how they will keep the application running during the move. That answer matters more than the tools they mention.

Frequently asked questions

Is it safe to keep running a CGI application?

It can be, for a while, if you reduce the risk around it. Limit who can reach it, remove unused scripts, keep the server patched, run it with minimal permissions and take tested backups. Treat this as a holding position while you plan a move, not a permanent answer.

Can a CGI application run on a modern server?

Often, yes. Most web servers can still run CGI scripts, and old Perl code can usually run under a modern Perl framework with modest changes. Older code may need small fixes for a newer Perl, so test on a separate copy before switching the live system.

Do we have to rewrite the whole application?

Usually not. A staged move lets you keep the parts that work and replace the riskiest or most changed areas first. The old and new code run side by side behind the same web addresses until each old piece can be retired safely.

How long does moving a CGI application take?

It depends on how many scripts there are, how much they share, how much testing exists and how far the platform is behind. A short read-only review gives a realistic plan and shows which stages can deliver value early.

What if nobody understands the code any more?

That is common with older systems. Start by recording what the application does from the outside: its pages, outputs and data changes. Tests built from that behaviour let someone change the code safely, even before they understand every part of it.

Need help with an old CGI application?

If you have Perl code that needs fixing, extending or moving to a modern setup, I’m happy to take a look. The Perl development page covers the kinds of work I take on, and how remote projects run.

You can reach me through the contact section or email me at manu@manu.co.in. A few lines about the system and what you need is a good start.

Back to the blog