Rare for a bear to attack unless you get too close to its cubs or it’s starving or rabid.
While attacks by female black bears with cubs happen, they are relatively rare. Most female black bears will abandon cubs instead of attacking. Rabid bears are a concern, of course.
As populations of black bears have increased nationwide, so have attacks by black bears. Grizzly bears are far more aggressive. Grizzly bears in the lower 48 states attack people about 200-300 times as often per bear compared to black bears. In the lower 48, there about about 200-300 times as many black bears as grizzly bears.
When I was about 18 or 19 I was somewhat of a dare devil and did something very stupid. Some friends and I were camping and fishing about 170 miles north west of Montreal in Quebec in the Verendrye Provincial park. After breakfast, we heard a cub bawling in a tree close to our camper. We cleaned up after breakfast and getting our fishing gear ready, and the cub was still up in the tree, about 20 feet up. No mama bear in sight, so I volunteered to shinny up the tree and rescue the cub. As I got to within about 3 feet of it, it was a bit larger than I thought, probably around 50 or 60 lbs. It took a swipe at me with claws that looked about 2 inches long. It suddenly dawned on me that this was not my best idea ever. I also wondered how far or worse how close mama bear was. If she came I would be dinner as I was still a good 10 - 15 feet up, with a pissed off full grown bear climbing up the tree and a crazy cub above, and my friends would probably run for their lives. I got down, went to the camper and splashed cold water on my head and face. Heard a thrashing in the underbrush, my friends yelling, looked out the camper door, and mama bear was at the bottom of the tree, and the cub was coming down on it’s own! It knew how to get down all along, but was a bit scared until mama came. That was the last bear cub rescue attempt for me.