A breach of credit and debit card data at discount retailer Target may have affected as many as 40 million shoppers who went to the store in the three weeks after Thanksgiving, the retailer said Thursday.

Late Wednesday, the Secret Service, which is charged with safeguard the nation's financial infrastructure and payment systems, confirmed it was investigating the breach.

The breach first came to light via a report from respected security researcher Brian Krebs that said Target had suffered a data breach around the time of Black Friday last month "potentially involving millions of customer credit and debit card records."

Target, the nation's No. 2 general merchandise retailer after Walmart Stores, said cards used at the brick-and-mortar stores between Nov. 27 and Dec. 15, 2013, may have been impacted.

The retailer said it notified authorities and financial institutions immediately after it was made aware of the unauthorized access, and had hired a forensics team to thoroughly investigate how the breach may have happened.

"Target's first priority is preserving the trust of our guests and we have moved swiftly to address this issue, so guests can shop with confidence," said CEO Gregg Steinhafel in a statement. "We regret any inconvenience this may cause."

The thieves reportedly gained access to data on the magnetic strips of shoppers' cards, potentially allowing them to produce counterfeit versions, according to Krebs.

The thieves could also potentially withdraw cash from ATMs using counterfeit debit cards if they were able to intercept PIN data from Target, he said.

American Express and Discover both said they were "aware" of the incident and had fraud controls in place.

"This is an ongoing investigation," an AmEx spokeswoman said, declining to comment further.

MasterCard referred questions to Target; Visa did not respond to requests for comment.

Target competitor TJX Companies -- which operates discount retail chains T.J. Maxx and Marshalls -- fell victim to one of the worst security breaches ever back in 2006, when hackers gained access to at least 94 million domestic and international accounts containing credit card, debit card, and check information.