It is not illegal to have cash, brokerage accounts or other investments in foreign countries.
It is, however, illegal to use those accounts to evade U.S. taxes by hiding that income.
There are significant reporting requirements for offshore assets, including FBAR (Report of Foreign Bank and Financial Accounts) filings.
Taxpayers who do not properly report and disclose those accounts are breaking the law and could face civil and criminal penalties and fines.
Pay attention to reporting requirements and if you need to make a disclosure because you failed to report in the past, you may want to consider the Offshore Voluntary Disclosure Program (OVDP).
Qualifying taxpayers who come in through the program can catch up on filing and payment requirements and avoid heavy fines and criminal prosecution.