A two-slot receptacle is not a defect on its own. It is simply what was installed when the house was wired, back when two-conductor cable with no separate grounding wire was standard practice. The problem starts when someone swaps it for a three-slot receptacle so a modern plug fits, without adding the ground that the third slot promises.
That swap is the single most common piece of unsafe amateur work found in older houses. The receptacle now looks grounded. A plug-in tester will often say it is fine. But nothing is connected to that third slot, so any appliance with a metal case has no path to clear a fault. The person holding the appliance becomes that path instead.
The code recognises that rewiring an entire house is not always practical, so it allows three specific answers when there is no equipment grounding conductor in the box. The first is to replace like for like, another two-slot receptacle. Nothing improves, but nothing is misrepresented either.
The second is to install a GFCI receptacle in that location, or feed the outlet from a GFCI upstream, and label it with the markings supplied in the device packaging. A GFCI does not create a ground. It watches for current leaving on the hot and not returning on the neutral, and cuts power in milliseconds when the two do not match. That protects people, which is the main risk, even though it does nothing for surge suppressors or equipment that genuinely needs a ground reference.
The third answer is to run an actual grounding conductor to the box, either by pulling new cable or by extending a ground from a point on the same system that is properly grounded. This is the only option that makes the three-slot receptacle honest.
Which one fits depends on what the outlet is going to power. A bedroom lamp is a different question from a home office full of electronics with surge strips that need a ground to work at all. The labelling step matters too, because the next owner deserves to know what is behind the wall rather than trusting a tester.
One more detail gets skipped often. Where a GFCI feeds several downstream receptacles on the same ungrounded circuit, every one of those downstream outlets needs the no-equipment-ground marking too, not just the device with the buttons on it. The protection travels down the circuit but the warning does not travel by itself.
Further reading: home electrical wiring
