Legacy code audit: a checklist for owners, buyers and investors
Before you buy a company, replace a developer, raise money or approve a rewrite, someone should look inside the software. This is a plain-language legacy code audit checklist: what to ask for, what to check, how to rate risk and how to turn the findings into a decision and a budget.
TL;DR
- An audit answers three business questions: Is the software safe to run? Can another team take it over? What will it cost to fix, extend or replace?
- Start with ownership and access (repository, cloud, domains, payment accounts). Missing keys are a bigger risk than messy code.
- Check eight areas: ownership, security, dependencies and runtime, code quality, data, deployment and operations, integrations, licenses.
- Rate each finding by severity and effort in a risk register, then decide: fix, contain or replace. Rewrites are the last option, not the first.
- Good audit output is a short report with a ranked list and rough effort bands, not a 200-page document.
A legacy code audit is a structured review of an existing software system: its code, infrastructure, data and the people and agreements around it. It is not a rewrite quote. The goal is to give an owner, buyer or investor an honest picture of risk and cost, in plain language.
We do these reviews as the first step of takeovers and stabilization projects. Our own method for the first weeks on a live system is described in legacy PHP handover; this article is the checklist version for non-engineers and their technical advisors.
When you need a code audit
- Acquisition or investment. Technical due diligence before you sign. Software that cannot be maintained or secured changes the price.
- Developer or agency change. The person who knew the system is leaving, or a vendor relationship is ending.
- Before a rewrite or a big feature. Rewrites are expensive and often unnecessary. An audit tells you what is actually broken.
- After an incident. A breach, a data loss or repeated outages are signals that the basics need checking.
- Compliance requests. Customers, insurers and partners increasingly ask for evidence of how software is secured and maintained.
What to prepare for the auditor
You can start the audit in a day if you gather these:
- Read-only repository access and the full commit history, not a zip file.
- Read-only access to production logs and monitoring, or a recent export of them.
- A list of every external service the system talks to: payments, email, SMS, maps, analytics, AI providers, partner APIs.
- A list of environments (production, staging) and how code gets from a laptop to production.
- Contracts with previous developers and agencies, especially anything about who owns the code.
Do not hand over production passwords for an audit. A good auditor works with read-only access and a copy of the database with personal data removed.
The checklist: eight areas
1. Ownership and access
- Who owns the repository, the cloud account, the domain, DNS, the payment processor account and app store listings? They should be accounts in your company's name, with your email as the owner.
- How many people can deploy? If the answer is one, you have a single point of failure (how many people the project depends on, the "bus factor").
- Where do secrets live (API keys, database passwords)? In a password manager or secret store is good; in the repository or in someone's chat history is a finding.
- Is there a signed IP assignment from every contractor who wrote code? Without it, you may not own what you paid for.
2. Security
- Known vulnerable dependencies (see the commands below).
- Authentication and sessions: password hashing, multi-factor option for admins, session timeout, rate limiting on login.
- Input handling: SQL queries built from user input, unescaped output (XSS), file uploads, CSRF protection.
- Secrets committed to the repository, debug mode enabled in production, publicly readable backups or
.envfiles. - Admin panels exposed to the whole internet instead of restricted by IP, VPN or an access layer.
3. Dependencies and runtime
- Language and framework versions. Software on an end-of-life runtime stops receiving security fixes. For PHP, check the official supported-versions table.
- Outdated or abandoned libraries, and forks of libraries that were patched by hand and never updated.
- Operating system and database versions and who patches them.
4. Code quality and architecture
- Size and shape: how many files and lines, how much duplicated code, how big the largest files are.
- Most-changed files: files that change in almost every commit and have many authors. These are where bugs live and where changes cost the most.
- Tests: do any exist, do they run, how long do they take? A system without tests can still be improved, but every change is riskier and slower.
- Static analysis level the code can pass (type coverage, obvious bugs).
- Documentation: a README that explains how to run the project, a map of the main flows and a list of scheduled jobs.
5. Data
- Database schema: missing indexes, tables without primary keys, very large tables, data duplicated in several places.
- Backups: do they exist, where are they stored, and has anyone ever restored one? An untested backup is a hope, not a backup.
- Personal data: what is stored, where, for how long, and who can see it. Is there a way to delete a customer's data on request?
6. Deployment and operations
- How is code deployed: git pull on the server, manual file copy, or a repeatable pipeline? Can you roll back in minutes?
- Monitoring and alerts: do you find out about downtime and errors before customers tell you?
- Log quality: are errors recorded with enough context to debug, and are logs rotated?
- Scheduled jobs (cron): documented, monitored, and safe to run twice?
7. Integrations
- Payments and webhooks: signature verification, idempotent handlers, reconciliation. See our guide to Stripe webhooks in PHP for what good looks like.
- API keys and tokens: where they are stored, whether they can be rotated without a code change.
- What happens when a third-party service is down: retries, timeouts, fallbacks.
8. Licenses
- Open-source licenses of the libraries you ship. Some licenses impose obligations on distribution or on proprietary code.
- Purchased themes, plugins and fonts: licensed to your company, and valid for your number of sites.
- Code copied from the internet or from a previous employer of a developer. Unclear provenance is a diligence risk.
Quick commands that surface real findings
An engineer can run these in an hour on a PHP project and get a first picture. Run them on a copy, not on production:
# Who knows this code? (bus factor)
git shortlog -sn --since="1 year ago"
# Most-changed files: files changed most often in the last year
git log --since="1 year ago" --name-only --pretty=format: | sort | uniq -c | sort -rn | head -20
# Size and languages
cloc . --exclude-dir=vendor,node_modules
# Known vulnerabilities in PHP dependencies
composer audit
# Outdated direct dependencies
composer outdated --direct
# Secrets committed to history
gitleaks detect --source . --redact
# Static analysis baseline (start low, raise later)
vendor/bin/phpstan analyse src --level=3
None of these is a verdict by itself. A large composer audit report on an unmaintained app is a strong signal; a handful of PHPStan errors on old code is normal. The point is to turn "it feels fragile" into a ranked list.
A simple risk register
Record every finding with the same fields so that you can sort and discuss them. Keep severity about business impact, not about how ugly the code looks:
ID Area Finding Severity Effort Action
01 Ownership Domain registered to former contractor Critical 1 day Transfer to company account
02 Security Admin panel open to the internet, no 2FA High 2 days Restrict by IP, add 2FA
03 Runtime PHP 7.4 in production (end of life) High 2-4 wk Upgrade plan, staged
04 Data Backups never restored High 2 days Restore test, document
05 Quality No automated tests on checkout flow Medium 1-2 wk Add smoke tests first
06 Deploy Manual FTP deploys, no rollback Medium 3 days Git-based deploy script
Use effort bands (hours, days, weeks, months) rather than false precision. Then group findings into three buckets: fix now (critical and high risk, cheap to fix), contain (risky but not urgent: add monitoring, restrict access, document) and plan (larger modernization work, like an upgrade of the runtime).
Fix, contain or replace: how to decide
- Fix when the architecture is sound and problems are local: outdated dependencies, missing backups, weak access control. This is the cheapest path in most audits.
- Contain and modernize in steps when the system works for customers but is hard to change. Wrap risky parts, add tests around the flows that make money, then upgrade piece by piece.
- Replace only when the system cannot be secured or extended at a reasonable cost, or the business model has moved on. Even then, run old and new in parallel and migrate by feature.
A useful sanity check: if someone proposes a full rewrite without an audit, ask what specific findings justify it. Rewrites discard years of encoded business rules and tend to take longer than estimates. For a lighter cousin of the audit that focuses on crawling, speed and indexing, see our technical SEO audit checklist.
Red flags and green flags
- Red: only one person can deploy; no one has restored a backup; credentials in the repository; production on an unsupported runtime; the former developer still holds the domain or cloud account; no written description of how the system works.
- Green: accounts under company ownership; repeatable deploys; logs and alerts; a README that a new developer could follow; tests on payment and login flows; a short, honest list of known issues.
What a good audit report contains
- A one-page executive summary: overall risk, top five findings, recommended path.
- The risk register with severity, effort band and recommended action.
- A system map: components, hosting, integrations and data flows in one diagram.
- A 30-60-90 day plan: what to do first, what to schedule, what to leave alone.
- Assumptions and limits: what was and was not reviewed.
How we can help
We review and take over live PHP, Laravel and Yii platforms, and we write the report in language your finance and legal people can read. If you are weighing an acquisition, a developer change or a rewrite, book a short consultation and we will tell you what an audit would cover for your system. For ongoing work on integrations after the audit, see our integrations service, and to see what we have run in production, browse our PebbleHost billing platform case.
Read also: Legacy system modernization: strategies, costs and a safe migration plan
Frequently asked questions
How long does a legacy code audit take?
A focused audit of a small or mid-size application usually takes from a few days to two weeks, depending on size, access and how many integrations exist. A quick first pass with automated tools can be done in a day to show the main risks.
What does a code audit cost?
Price depends on system size and depth: a short triage, a full audit with a written report and a due-diligence review for an acquisition are different scopes. Ask for a fixed scope with a deliverable (risk register and plan) rather than an open-ended hourly engagement.
Do I need to give the auditor access to production?
Not write access. Read-only access to the repository, logs and monitoring, plus a copy of the database with personal data removed, is enough for most audits. Never share root or admin passwords for an audit.
Is old PHP code always a problem?
No. Old code that runs on a supported runtime, has backups, monitoring and limited known vulnerabilities can be perfectly fine. The risks are an end-of-life runtime, outdated dependencies, missing ownership and no one who understands the system.
Should we rewrite or fix a legacy system?
In most cases fix and modernize in steps. Rewrite only if an audit shows the system cannot be secured or extended at reasonable cost, and even then migrate feature by feature while the old system keeps running.
Free discovery call
Bring a messy stack or stalled integration - Integrono will map the smartest first move.
You get a senior take on budget traps, dependencies and whether to buy, glue or build - before paid work starts. The CEO stays in the loop.