A recent study by a multinational team suggests sick chimpanzees go out of their way to find plants with antibacterial and anti-inflammatory properties. This behaviour has been reported for other great apes too. See a recent post about an orangutan who successfully treated a bad face wound received in a fight.
But chimpanzees use more plant medicines than any other animal, according to the team. They propose adding 17 samples from 13 plant species to the chimp pharmacopeia. They even suggest that some of these plants might be added to our own pharmacopeia. The plants identified include the rotting trunks of certain trees, various leaves, and even ferns.
The “chimp pharmacopeia” is an informal list kept by human naturalists. Nobody really knows how chimpanzees gain and pass on this knowledge, but it is likely a combination of trial-and-error, watching others, and being deliberately taught by other chimps, especially their mothers and close family.