Yahoo Inc. executives detected hackers in their systems in fall 2014 who they believed were linked to Russia and were seeking data on 30 to 40 specific users of the company’s online services, a person familiar with the matter said.

The person familiar with the matter didn’t know whether that attack led to the theft of information on 500 million user accounts, which Yahoo disclosed Thursday. In that disclosure, Yahoo said the information was stolen from its network in late 2014 by a “state-sponsored actor.”

The...