I opened a new jar of spaghetti sauce and there was a dark hard substance like old mold on the rim. There was none inside the jar and the jar seemed to have been sealed properly. Is the sauce safe to consume?
Mold is a fungus and like other fungi it consists of a nearly invisible mycelium and a visible part producing the spores, the mushroom or in the case of mold the hairy stuff called the sporangium. As the rim part of the jar is under the lid I would consider it being inside the container and so there is a chance the mold already has spread into the sauce even if it has not grown the visible parts yet. In general molds produce mykotoxines so food with mold on it should never considered safe to eat (exceptions: blue cheese, tempeh, ...), especially because this mykotoxines can distribute and contaminate parts of the food that are not (yet) directly affected by the mold.
On the other hand 'dark hard substance' does not sound like a typical description of mold. You might want to double check if it is not just dried sauce or provide a picture of it for clearer identification.