Monday, 8:40 a.m. The partner commission system did not produce the January statement. On the server a process somebody named job7 is running, and the database holds 63 tables, half of them called things like TMP_COR2. The developer who wrote the system nine years ago has worked elsewhere for four years. The vendor that maintained it afterwards ended the contract last year and handed over an archive of executables and something that was supposed to be source code but does not build. The CFO wants to know when partners will be paid.

That is how reverse engineering usually starts in a company: not out of curiosity, but because of an outage, a vendor exit or a modernisation decision that cannot be planned because nobody knows what the system actually does. The CTO then faces two questions at once. How do you recover knowledge nobody wrote down? And what are you allowed to do with code your company may not own?

This article defends a position that sounds unnatural to many engineering teams: reverse engineering an undocumented system should start with observing the running system and its data, not with reading the code, and certainly not with a decompiler. The output should be an executable specification, meaning tests that pin down current behaviour, not a thick document in a wiki. That order is faster and cheaper, and, which turns out to be decisive for many companies, it is the safest one legally on both sides of the Atlantic.

What is software reverse engineering, and how does it differ from copying?

Reverse engineering is the analysis of an existing system to understand how it is built and how it works. The classic definition comes from Elliot Chikofsky and James Cross in “Reverse Engineering and Design Recovery: A Taxonomy”, published in IEEE Software in 1990: the process of analysing a subject system to identify its components and their interrelationships, and to create representations of the system in another form or at a higher level of abstraction. The same paper separates reverse engineering from what may follow it: restructuring, which changes code without changing behaviour, and re-engineering, which builds a new version from the recovered knowledge.

That definition has a practical consequence that is easy to miss. Reverse engineering on its own changes nothing and copies nothing. Its product is knowledge: a data model, an integration map, a description of business rules, a dependency list. Copying begins when fragments of someone else’s code end up in a new system. The line matters technically, because knowledge of business rules survives a change of technology while copied code carries old defects forward. It also matters legally, because copyright protects the expression of a program, not its ideas or functionality.

In companies, reverse engineering usually serves one of four purposes. Maintenance: fixing a defect in a system nobody understands. Integration: connecting a new system to an old one with no documented interface. Migration or modernisation: knowing exactly what has to be moved. Vendor exit: the contract is ending and the knowledge sits on the vendor’s side. Each needs a different depth of analysis and, as you will see, rests on a different legal basis.

Do not confuse this with a full legacy modernisation programme, whose strategic choices we discuss in our piece on facing legacy system modernisation wisely. This article deals with an earlier, narrower stage: the moment when you do not yet know what you have and must find out before deciding anything about fixing it.

Why start by observing the running system rather than reading the code?

Because code answers “how”, and in the first weeks you need answers to “what” and “why”. A system with nine years of history contains dead code, code that runs once a year, workarounds for defects long fixed elsewhere and features nobody uses. Reading it front to back means giving critical and dead paths the same attention. Observing the running system shows immediately which paths are used, how often and by whom.

The scale of the problem is well measured. Xin Xia and co-authors published “Measuring Program Comprehension: A Large-Scale Field Study with Professionals” in IEEE Transactions on Software Engineering in 2018. They tracked 78 professional developers across seven projects over 3,148 working hours and found that developers spend roughly 58% of their time comprehending programs rather than writing code. Those were projects with living authors, documentation and change history. In an undocumented system the share is higher, and every hour of aimless code reading is an hour that does not move you closer to an answer.

The second argument is less obvious. Code shows what the system could do. Data and network traffic show what it actually does. In the commission system from our example, the code may contain five calculation variants, while the results table for the last three years contains only two. That is something you cannot read from the code, and it halves the scope of work on the spot.

The third argument is about verification. A hypothesis built from reading code still has to be checked against the running system. A hypothesis built from observation is checked from the start, because it comes from real behaviour. Code reading then stops being exploration and becomes confirmation: you look for the place that produces behaviour you already know.

A competent opponent will say observation misses rare paths such as year-end close or credit-note handling. True, which is why observation does not replace reading code but comes before it. Rare paths are easier to find once you know the common ones, because less code is left to examine and your questions to users become specific: “what happens in December that we did not see in January?”

Before running anything, establish who owns the copyright in the system. That decides how much of the rest of this article applies to you. Code written by employees in the course of their duties usually belongs to the employer; in the EU, Article 2(3) of Directive 2009/24/EC gives the employer the economic rights unless otherwise agreed, and the US work-for-hire doctrine leads to a similar result. Code written by a vendor is a different matter. Without an explicit assignment of rights you most likely hold a licence, sometimes only an implied one, and the code belongs to the vendor. National formalities vary: in Poland, for example, an assignment of economic rights must be in writing and list the fields of exploitation. Our article on who owns the code in IT projects covers the ownership side in more detail.

If you own the rights, copyright places no limits on analysing, decompiling and modifying your own system. The limits remain for third-party components: commercial libraries, reporting engines, drivers, frameworks under end-user licence agreements. A system with nine years of history almost always contains several of these, and each needs to be treated separately.

If the vendor owns the rights, you are working within the exceptions. In the EU the most important one for reverse engineering is Article 5(3) of Directive 2009/24/EC on the legal protection of computer programs: a person with a right to use a copy of a program may, without the rightholder’s authorisation, observe, study or test the functioning of the program to determine the ideas and principles underlying any of its elements, while loading, displaying, running, transmitting or storing it. Member states have transposed this into national law; the UK kept an equivalent in section 50BA of the Copyright, Designs and Patents Act 1988.

The provision is broader than it looks. Running the system on test data, capturing network traffic, analysing the database structures the system creates, measuring response times and comparing inputs with outputs all fall within observing and testing while running the program. In its judgment of 2 May 2012 in case C-406/10 SAS Institute v World Programming, the Court of Justice of the EU confirmed two points that matter here. First, the functionality of a computer program, its programming language and the format of its data files are not protected by copyright as the expression of the program. Second, a licensee may observe, study and test the program to determine its ideas and principles, provided it does not infringe the rightholder’s exclusive rights.

The US picture is different in mechanism but similar in direction for observation. Section 102(b) of the Copyright Act excludes ideas, procedures, processes, systems and methods of operation from protection, so describing what a program does is not infringement. The conclusion for a CTO: the most important part of the work, recovering what the system does, rests on ground that is broad in the US and, in the EU, on an exception the vendor cannot take away by contract. That is why “observe first” is not only technically sensible but also the safest order legally.

When is decompilation lawful: interoperability and error correction?

Decompilation, turning executable or intermediate code into something close to source code, is in legal terms reproduction of the code and translation of its form. In the EU it is allowed without the rightholder’s authorisation in two situations.

First: interoperability. Article 6 of Directive 2009/24/EC allows reproduction of the code and translation of its form where indispensable to obtain the information necessary to achieve interoperability of an independently created program with other programs. Three conditions must all be met: the acts are performed by the licensee or another person entitled to use the program, or on their behalf; the information needed for interoperability has not previously been readily available; and the acts are confined to the parts of the program necessary for interoperability. Article 6(2) then limits use of the results: the information may not be used for goals other than interoperability, may not be given to others except when necessary for interoperability, and may not be used to develop, produce or market a program substantially similar in its expression.

In practice: if you are building a new module that must exchange data with the old system, the message format is undocumented and the vendor will not disclose it, you may decompile the part that produces that format. You may not decompile the whole system just in case, nor use the result to write a clone.

Second: error correction. Article 5(1) of the directive allows a lawful acquirer to perform acts necessary to use the program in accordance with its intended purpose, including error correction, in the absence of specific contractual provisions. In its judgment of 6 October 2021 in case C-13/20 Top System v Belgian State, the CJEU held that the lawful acquirer may decompile the program, in whole or in part, for that purpose. The limits: decompilation only to the extent necessary to correct an error that affects the program’s operation in line with its intended purpose, and in compliance with the contract, which, according to commentary on the ruling, may regulate how error correction is exercised but may not rule it out altogether. Advocate General Szpunar’s opinion in the case noted that the concept of an error does not include technological obsolescence, so “error correction” is not a back door to modernisation. The Court also did not require the Article 6 conditions to be met for error correction.

In the US, the leading authority is Sega Enterprises v. Accolade (9th Cir. 1992), where the court held that disassembly of object code is a fair use where it is the only way to gain access to the unprotected functional elements of a program and there is a legitimate reason for seeking that access. The Digital Millennium Copyright Act adds 17 U.S.C. §1201(f), which allows a lawful user to circumvent a technological protection measure to identify and analyse the elements needed for interoperability of an independently created program. Neither creates a general right to decompile for documentation’s sake, and fair use is decided case by case.

Note what is missing from all of these rules. There is no general right to decompile in order to understand a system, document it or prepare a migration. You achieve those goals through observation and testing, which are broadly permitted, not through decompilation, which is narrowly permitted. That is one more argument for the order proposed here.

A caveat that belongs in every plan: this article describes statutes and case law, not your contract. Before decompiling a component you do not own, get a short written opinion from counsel based on the actual licence text. It costs less than a dispute with the vendor.

What can a vendor licence prohibit, and what can it not?

Many licences contain a blanket clause: “the licensee shall not decompile, disassemble or otherwise reverse engineer the software”. The clause is not worthless, but how far it reaches depends on jurisdiction and on what it covers.

In the EU, Article 8 of Directive 2009/24/EC states that any contractual provisions contrary to Article 6 or to the exceptions in Article 5(2) and (3) are null and void. A contract therefore cannot validly prohibit observing, studying and testing the program while using it, nor decompilation indispensable for interoperability on the statutory terms. In the UK, section 296A of the CDPA does the same job. A clause banning “all reverse engineering” is void to that extent.

Error correction is different. Article 5(1) applies “in the absence of specific contractual provisions”, so a contract may regulate it, for example by requiring you to report defects to the vendor and give it time to fix them. Following Top System, it cannot remove the possibility entirely. If the vendor has disappeared and the contract says only the vendor may fix defects, you need a legal assessment, not an assumption that everything or nothing is allowed.

In the US the balance tips towards the contract. In Bowers v. Baystate Technologies (Fed. Cir. 2003), the court held that a shrink-wrap licence term prohibiting reverse engineering was enforceable and not pre-empted by copyright law, even though reverse engineering might otherwise have been fair use. For US-governed licences, assume the clause binds you unless counsel says otherwise.

The third area is the one most often overlooked: trade secrets. Under Article 3(1)(b) of the EU Trade Secrets Directive 2016/943, acquiring information by observation, study, disassembly or testing of a product that is lawfully in the acquirer’s possession is lawful, but only if the acquirer is free from any legally valid duty to limit the acquisition of the trade secret. Here the contract counts. A reverse engineering ban may be void under copyright law and still effective as a limitation under trade secret law if the program embodies information the vendor protects as a secret. In the US, the Defend Trade Secrets Act states that reverse engineering is not an improper means of acquisition, but a contractual ban can turn it into a breach of contract.

The practical conclusion: read the licence and the non-disclosure agreement together, not separately. In many companies they sit in different folders with different owners, and that gap is where the risk lives. If you are ending or planning to end a vendor relationship, secure the code, documentation and access before you announce it. The cheapest reverse engineering is the kind you never need, because the vendor handed over code, documentation and access before the relationship ended.

Where do you start in the first week?

With an inventory, not analysis. The first week answers the question of what the system actually is, because in undocumented environments the boundary of the system is often unknown. A batch job launched by a scheduler on a file server, a spreadsheet macro somebody runs monthly, a database view the finance system reads from: all of these are part of the system, though none of them sits in a repository.

The first-week list has five items.

Environments and processes. Which servers, virtual machines or containers run the system; which processes run continuously and which on a schedule, with which parameters. Export the scheduler configuration, the list of system services and the environment variables. This is often the first place you find the addresses of the systems yours talks to.

Access and secrets. Who holds administrative accounts, where the database and external API credentials live, which certificates expire in the coming months. In systems abandoned by a vendor this is often the most urgent item, because an expired certificate will stop an integration faster than you can understand it.

Artefacts. What you have: source code, executables, database scripts, configuration, backups. And the key question: does the code you hold match what runs in production? Check by building it and comparing the result with the deployed version. If they differ, you know part of the knowledge will come from executables, and you know exactly where the legal questions begin.

People. Who uses the system, who changed it, who reported defects. Former vendor staff, the accountant who has corrected results by hand for years, the administrator who knows the order in which services must be restarted. Five 45-minute conversations can yield more than a week of code reading, provided the questions are specific.

External dependencies. Which commercial licences are in use, which are active, which components have known vulnerabilities. This feeds the risk assessment and also lists the elements to which the legal limits above apply.

The output of week one is a single page: a system context diagram with data flows, an artefact list with status and a list of open questions. No more. If you have thirty pages after a week, you have started documenting before understanding.

How do you recover knowledge from the database and production data?

In older business systems the database is the most reliable source of knowledge. Code changed, people left, but the data stayed, and its structure holds decisions nobody wrote down. Foreign keys tell you which entities are related. Unique constraints tell you what the system does not allow. Triggers and stored procedures hold business rules, often the most important ones, because they were added in a hurry “at the database level, so it definitely works”.

Start with the schema: generate an entity-relationship diagram from the database’s system catalogue. Then profile the data: for each table, the row count, the date of the last change, the distribution of values in status columns and the share of nulls. A table with a million rows untouched for six years is a candidate to skip. A table with twenty rows that change once a month is probably business-rule configuration and needs to be understood first.

The most effective technique here is change observation. Snapshot the database before and after a business operation, for example before and after generating the commission statement, and compare. You will see which tables the system reads, which it writes and in what order. On a test database with a copy of the data that is a few hours of work, and it yields a map you would not reconstruct from code in a week. If the database supports change logs or query tracing, switch them on for the operation in the test environment.

Mind the personal data. A copy of a production database in an analysis environment is processing of personal data, and for EU data subjects the data minimisation principle in Article 5(1)(c) GDPR applies; in the US, sector rules such as HIPAA or state privacy laws may apply instead. Where possible work on anonymised or pseudonymised data, and if the analysis needs real data, limit who has access and how long the copy is kept. Reverse engineering is not an exemption from data protection.

The output of this phase: a data model describing the meaning of the key tables and columns, a list of business rules embedded in the database and an “operation → tables read and written” map. That map is the skeleton on which everything you learn later will hang.

How do you recover knowledge from network traffic, logs and integrations?

The second source of knowledge is the system’s boundary: everything that comes in and goes out. In undocumented systems, integrations are the most frequent cause of failure during change, because the partner on the other side expects a format nobody described, and changing one field can stop bank settlements or order shipping.

Start by capturing traffic in a test environment or, if that is the only option and you have authorisation, in production with filtering for sensitive data. For HTTP interfaces, an intercepting proxy records requests and responses, and a few hundred recorded exchanges are enough to reconstruct the interface contract: endpoints, methods, message structures, error codes. Write that contract down straight away in a machine-readable format such as an OpenAPI specification, because it will drive contract tests later. For file exchanges, collect samples from several months, including year-end and correction periods, because formats often vary conditionally.

Application logs, even poor ones, say more than you would expect. Message frequency shows the hot paths. Errors that appear daily and are ignored point to known workarounds. Correlating timestamps with the scheduler lets you tie batch jobs to business operations. If there are practically no logs, consider adding application monitoring at the infrastructure level, which needs no code changes and falls within observing the program while it runs.

Everything in this section is observation and testing. In the EU, data file formats and exchange protocols are not protected as the expression of a program, as SAS Institute confirmed, so you may describe them, document them and reproduce them in a new system without infringing the vendor’s copyright, provided you did not learn them through decompilation that went beyond the statutory exceptions.

How do you read the code once you know what you are looking for?

After three or four weeks of observation you have a map of business operations, a data model, interface contracts and a list of questions observation could not answer. Only now does code reading become efficient, because it has a purpose: to find the place that produces known behaviour and to answer specific questions.

A few techniques shorten this phase. Start from entry points: begin with the code that handles observed requests, batch jobs and triggers, not with the directory structure. Use change history: if you have a repository with history, the files changed most often in recent years, and the commit messages, show which parts were patched most and are therefore the most fragile. Use static analysis and dependency graphs: code analysis tools reveal dead code, cyclic dependencies and the modules everything else depends on. Search by data: the table and column names identified earlier are the best search keys in the code.

AI coding assistants can speed this phase up by summarising unfamiliar modules and proposing function descriptions. Two cautions. The technical one: the model summarises what it sees, not what the system does, so its description must be verified by a test just like a developer’s hypothesis. The legal one: if you are analysing code you do not own, or code obtained by decompilation, sending it to an external service may amount to giving the information to others, which Article 6(2) of the EU directive restricts outside what interoperability requires, and it may breach the confidentiality terms of your vendor contract. Settle this before the first use, not after.

Where does decompilation fit in this phase? Only where you have no source code and the specific question concerns interoperability or correcting an error. If the goal is migration to a new system, decompilation is particularly risky, because information obtained that way may not be used to develop a program substantially similar in its expression. The new system should be built from knowledge gained through observation, meaning functions, rules and formats, not from decompiled code. That is the principle behind what is often called clean-room design: the people writing new code work from a specification of behaviour, not from someone else’s code. The approach has a long history in the US as well, where it has been used to show independent creation.

How do you turn recovered knowledge into characterization tests?

This is where most reverse engineering efforts lose their value. The team recovers knowledge, writes it into a document, the document lands in a wiki, and six months later nobody knows whether it is current. An undocumented system becomes a system with out-of-date documentation, which is worse, because it gives false confidence.

Michael Feathers described the alternative in “Working Effectively with Legacy Code” (2004). A characterization test does not check whether the system behaves correctly; it pins down how it behaves now. You supply an input, record the output, and the test makes sure the next change does not alter that output without you knowing. Feathers defines legacy code simply as code without tests, which captures well where the problem lies.

In an undocumented system, characterization tests serve as both documentation and safety net. Every rule recovered in the earlier phases becomes a test: “for a category B partner with turnover above the threshold, the commission is X”. Every interface contract becomes a contract test. Every “operation → tables” map becomes a database-level test. A specification like this cannot quietly go stale, because a discrepancy makes a test fail.

The most effective variant for old systems is the golden master: record the system’s full output (a report, an export file, a set of database records) for a representative set of inputs, and compare every subsequent run against it. You do not need to understand every number in the report to know that it has not changed. Understanding comes gradually as discrepancies point to parts worth describing.

For reverse engineering there is one more advantage: characterization tests built from observed behaviour are entirely the product of activities permitted under Article 5(3) of the directive. The specification is yours, whoever owns the code. When the time comes for regression testing after the first changes, or for paying down technical debt through refactoring, the suite already exists.

What does a six-week plan look like, and what does it cost?

The plan below assumes a mid-sized system: a few dozen tables, several integrations, one main technology and partial access to source code. For larger systems the phases stretch, but the order stays.

WeekPhaseMain activitiesOutputLegal basis if the vendor owns the code (EU / US)
1InventoryEnvironments, processes, access, artefacts, user interviewsContext diagram, artefact list, open questionsUse of the program for its intended purpose
2DataSchema, profiling, before-and-after snapshotsData model, operation → tables mapObserve, study, test (Art. 5(3)) / ideas and methods unprotected (§102(b))
3System boundaryTraffic capture, file samples, log analysisMachine-readable interface contractsObservation and testing; data formats unprotected (C-406/10)
4Targeted code readingEntry points, change history, static analysisBusiness rules traced to codeRequires source code or rights to it
4–5Decompilation (only if needed)Narrow parts with no source codeAnswer to a specific questionInteroperability (Art. 6) or error correction (Art. 5(1), C-13/20) / fair use, §1201(f), subject to licence
5–6Pinning downCharacterization tests, golden master, contract testsExecutable specification in CIProduct of observation, independent of code ownership
6DecisionRisk assessment, optionsRecommendation: keep, fix, modernise, replaceNot applicable

Cost is mostly the time of experienced people. A realistic team for such a system is two senior engineers: one strong in databases and integrations, the other in the technology the system is written in. Six weeks of two people is about 480 hours. Multiply that by your blended rate: at an illustrative EUR 60 per hour the total is about EUR 29,000, and at the rates of senior contractors in Western Europe or the US it will be considerably higher. Treat this as an estimate, not a quote. It rises with the number of technologies (a system in three languages needs three skill sets), with the number of integrations and with missing source code, which forces decompilation and a legal opinion. It falls when people who know the system are available.

Add the costs on your side: users’ time for interviews, a test environment with a data copy and, possibly, a legal opinion on the licence. The first is the one most often underestimated. Without two or three hours a week from people who know the business process, the technical team will recover how the system works but not why.

If you are not sure six weeks will be enough, a cheaper first step is a fixed-scope audit. At ARDURA, the Code Health Audit and technical due diligence start from EUR 4,500 for the audit, take one to two weeks and end with a risk assessment and a remediation plan. That does not replace reverse engineering, but it lets you plan it properly.

When should you stop recovering knowledge and decide whether to fix, modernise or replace?

Reverse engineering has a natural tendency to expand: there is always one more module you do not fully understand. You therefore need an exit criterion agreed up front, not a feeling that “it’s enough”.

A good criterion reads like this: the first stage ends when every critical business operation has a characterization test, every integration has a machine-readable contract and the open-questions list contains only questions about rare paths, each with an assigned way to investigate it. Critical operations are those whose stoppage costs the company money within a day or a week. In the commission system that means calculation, the statement and the payment export, not every auxiliary report.

With that material, deciding what comes next stops being guesswork. If the recovered knowledge shows a reasonably structured system used in predictable ways, the cheapest path is often to maintain it and fix it gradually under the cover of tests. If it shows a system whose rules fit on a few pages but whose code cannot be maintained, staged replacement is often sensible. We covered the modernisation strategies in our strategic guide to application modernization, so we will not repeat them here.

There is a third outcome engineering teams dislike: the recovered knowledge shows that most of the system is unused and the critical functions can move into an existing company system or an off-the-shelf product. Reverse engineering that ends with “we switch off 70% of the code” is not a failure. It is the best possible return on six weeks of work.

Which mistakes should you avoid in reverse engineering?

Five mistakes recur often enough to name them outright.

Decompilation as the first step. The team receives executables, runs a decompiler and starts reading the output. It loses weeks on code that is often unused and walks into legal constraints for no reason. Observation yields the same functional knowledge faster and without the risk.

A document instead of tests. Knowledge written into a document starts ageing the day it is written. Knowledge written into tests signals when it stops being true.

Analysis without users. A system reconstructed only by the technical team is a description of code, not of a process. A rule that looks like a bug may be a deliberate business decision from years ago, and an apparent defect is not always the thing to fix.

No legal boundary inside the team. If some people on the team have seen the vendor’s decompiled code and others are writing the replacement, agree rules for information flow before work starts. The requirement not to use such information to build a substantially similar program is easier to meet organisationally than to prove after the fact.

No exit criterion. Without one, knowledge recovery becomes a standing cost and the decision about the system’s future keeps slipping. Write the criterion from the previous section into the engagement, whether the work is done in-house or by an external team.

To this list add a mistake from the past that costs money now: vendor contracts without an obligation to hand over source code, documentation and knowledge. If you are drafting new contracts, make sure the next team does not have to go through the same process. We discuss this risk at length in our article on avoiding vendor lock-in.

What are the key takeaways for a CTO?

An undocumented system is not a system without knowledge. The knowledge is in the data, the network traffic, the logs, the users’ heads and, last of all, in the code. The order in which you extract it determines cost, time and legal risk.

Remember six things. First, establish who owns the copyright in the system and its components before anyone launches a decompiler. Second, start with an inventory and observation of the running system, because they show which paths are really used, and in the EU your right to observe, study and test does not depend on what the licence says. Third, treat the database and the integrations as the most reliable sources of business rules. Fourth, read code with a purpose and specific questions, and use decompilation only for interoperability and error correction, to the extent necessary and within the licence where the licence lawfully applies. Fifth, capture recovered knowledge in characterization tests and contracts, not in a document that will be stale within a quarter. Sixth, agree an exit criterion up front and end the stage with a decision: keep, fix, modernise or replace.

If you have a system nobody in the company understands any more, and stopping it would cost more than a few weeks of two senior engineers, see how we approach software rescue at ARDURA Consulting or book a conversation. We start with a fixed-scope audit that shows what you have, what the risk is costing you and where knowledge recovery should begin.