What does a goodly apple rotten at the heart mean?

as I understand it, a goodly rotten apple is someone (or something) who is a part of system, a group, who is themselves bad and will likely corrupt the other members of the group, cause trouble, etc...