In this week’s episode of Silicon Valley, Richard enjoyed an unprecedented run of success, culminating with the official launch of Pied Piper’s platform. Richard has suffered so many setbacks, it’s little wonder he is initially reluctant to launch even a beta version—certain that the platform is buggy and will only subject Pied Piper to further mortal embarrassment. But the team convinces him to try a very limited, private beta, and the embarrassment never comes. Everyone loves it, from the beginning to the shockingly happy ending… everyone, except Monica. (But that doesn’t matter because her dissatisfaction just convinces us that we aren’t dreaming.) The team even manages to foil Gavin Belson’s attempt to steal the beta, turning the tables on him and leaving him screaming to “cut the power to building” in order to shut down the team’s zip bomb.

But the making of this happy story involves an amazing number of privacy invasions and downright dirty tricks, led by the budding uber-villain Gavin Belson. Through his scheme of monitoring employees’ emails, Gavin discovers that Pied Piper released its beta, and Gavin unleashes Hooli’s head of security to fraudulently obtain a copy of the beta by impersonating one of Richard’s friends. But Pied Piper’s hands are not entirely clean either. Pied Piper finds out someone at Hooli has their beta because Gilfoyle enabled ‘god view’ and can monitor the precise location of all the app’s users. Gilfoyle disables the stolen copy (and via Gavin’s hysteria, all of Hooli) by using the app to send a zip bomb to Gavin’s phone and laptop. Richard uses the god view to stalk Monica to a hookah bar and confront her about her dislike of the beta. One starts to wonder just how much sneakiness and skulduggery it takes to make each happy moment of Silicon Valley.

There is so much material to cover, I’ll start with the easy one: Hooli likely did not violate any laws by monitoring employee email. In general, when an employer owns the email system, network and/or computers, the employer is allowed to monitor the contents of all of those. Employees generally have no expectation of privacy for things they do on their employers’ computers or messaging systems.

But that’s where Hooli’s compliance ends, and its crimes and torts begin. First, it is a misdemeanor (a crime) in California to “credibly” impersonate someone else electronically or online, without their consent, for purposes of harming, intimidating, threatening, or defrauding another person. When Hooli’s head of security set up a fake email account and impersonated Richard’s friend Max in order to illicitly obtain Pied Piper’s beta, he clearly violated this California law. More than that, he committed good-old, garden-variety fraud. Someone commits fraud by making a false statement of an important fact, knowing the fact is false but intending that someone else rely on it, and the other person reasonably relies on it, and is harmed as a result. Hooli’s security guy knowingly misrepresented his identity, intending for Richard to rely on the false identity, Richard reasonably relied on the false identity and was tricked into giving up something valuable: access to his beta. That’s fraud! On top of that, the security guy likely committed theft of trade secrets (by using a misrepresentation to acquire the beta) — I could go on, but it seems unnecessary.

Given all Gavin’s scheming, it was satisfying when Gilfoyle retaliated by delivering a zip bomb to Gavin’s phone and laptop, and even better when Gavin freaked out and shut down all of Hooli in an attempt to contain the bomb. Alas, our hero’s actions also might have bent or broken a law or two. One of the primary laws to worry about is the Federal “Computer Fraud and Abuse Act” or “CFAA,” and similar state laws. The CFAA prohibits various kinds of “hacking” including accessing a computer “without authorization” or “exceeding authorized access” to obtain information, or to commit fraud and obtain something of value. Gilfoyle could argue that by installing Pied Piper’s app, Gavin “authorized” the app to be on his phone and computer and to do things like communicate with Pied Piper’s servers and download data. Therefore, there was no ‘unauthorized access,’ nor did Gilfoyle “exceed authorized access.” This is a really interesting argument and I don’t have nearly enough space to explore it. Fortunately for Gilfoyle, he didn’t obtain any information or try to commit fraud, so for that reason, he didn’t violate these portions of the CFAA.

However, the CFAA also prohibits knowingly transmitting a “program, information, code, or command” to cause damage “without authorization” to a computer, or intentionally accessing a computer “without authorization” and causing damage or loss. In this context, “damage” means any impairment to the integrity or availability of data, a system, or information. Courts have held that “damage” can include flooding an email account or server if it causes some sort of “impairment” to functioning of the target computer or system. This is where Gilfoyle looks to be in trouble, because he knowingly transmitted the zip bomb, which clearly impaired Gavin’s phone and computer, and Gilfoyle was not authorized to cause this “damage.”

It turns out it’s pretty difficult to take offensive measures or engage in counter-hacking without potentially breaking the law—and many argue this is a good thing. Even the newly-enacted Cybersecurity Information Sharing Act of 2015 (“CISA”) doesn’t provide blanket authorization for counter-hacking or offensive measures. CISA authorizes “defensive measures,” which are measures to detect, prevent or mitigate cybersecurity threats or vulnerabilities. However, CISA excludes any measures that destroy, substantially harm or provide unauthorized access to someone else’s systems, or data on someone else’s systems. In other words, those who engage in CISA-authorized “defensive measures” still have to be pretty careful not to substantially harm or obtain unauthorized access to others’ systems. CISA probably doesn’t give Gilfoyle cover for deploying the zip bomb.

What about Pied Piper’s use of ‘god view’ to track Monica and find out that Gavin was using the app? That was probably ok, and will be ok going forward—as long as Pied Piper adequately informs users that they will be tracked, explains how the tracking data will be used or shared with third parties, and obtains consent (preferably with a click-box or button, but at minimum because users install and use the app after being informed of the tracking). However, precise location data is sensitive information, and if Pied Piper continues to collect it, Pied Piper should implement security and internal controls to prevent employees from misusing the data. That means Richard should stop using the information to chase Monica around town.

Pied Piper finally launched its platform and Gavin Belson cut his own power, but we’ll have to see if this blissful state can continue into another episode.