Vents that go through drywalled ceilings from either furnaces or water heaters sometimes are moisture stained from leaks in roof flashings but sometimes they are also stained from condensation. If the roof flashing is good and the vent is vertical with no roof flashing leak, is there an issue other than a cosmetic issue?
If there’s condensation, that’s a problem.
B vent should have 1" clearance from combustibles including drywall, single wall pipe 6" clearance, the correct installation would be to have a fire stop where B vent penetrates a ceiling.
The attic should also be sealed unless it is conditioned, so there should be no openings the ceiling that will allow conditioned air to enter an unconditioned attic, the moisture from condensation is probably a result of conditioned air leaking into the attic.