In a comment posted on Investorshub in February, Mr. Shkreli defended his actions by claiming that “every transaction I’ve ever made at Retrophin was done with outside counsel’s blessing (I have the bills to prove it), board approval and made good corporate sense.” That certainly makes it sound as if the lawyer was working on behalf of the chief executive.

But if the Justice Department’s charge against Mr. Greebel is true, then the first misstep appears to be that he put Mr. Shkreli’s interests ahead of Retrophin, his actual client.

Mr. Greebel has pleaded not guilty and is fighting the charges.

There is nothing inherently wrong with settling a case by creating a consulting arrangement, unless it is done to mislead the company making the payment into believing it is a legitimate transaction. The reference in his email to Mr. Shkreli about avoiding scrutiny from the outside auditor can be evidence that the agreements were not intended to protect the corporate client but rather to mislead it, something a company’s lawyer is certainly not supposed to do.

Unlike a hedge fund investor who falls for a pitch from a fast-talking entrepreneur, shareholders depend on the company to have in place the protections needed to ensure it is being properly managed.

Since the demise of Enron in 2002 after its lawyers did little to protect the company from wrongdoing by its executives, corporate counsel is now seen as one of the gatekeepers for a corporation required to ensure that it stays within the law. When the company’s lawyer steps out of that role by aiding a chief executive in advancing his own interests, one of the key protections in place for investors is lost.

The Securities and Exchange Commission, which also filed civil fraud charges against Mr. Shkreli and Mr. Greebel, has emphasized that it wants to focus on corporate gatekeepers for failing to protect companies and their investors from fraud.

Kara M. Stein, an S.E.C. commissioner, raised the issue of whether the agency was not being tough enough in pursuing lawyers for misconduct at corporate clients. “Are we treating lawyers differently from other gatekeepers, such as accountants? I think we should carefully review the role that lawyers play in our markets, with a view towards how they can better help deter misconduct and prevent fraud,” she said in a speech in 2014.