Sheryl Sandberg has a message for college grads: be "clear-eyed optimists."

The Facebook COO addressed graduates at Massachusetts Institute of Technology on Friday, urging them to pursue work that supports equality, democracy, truth and kindness.

But she emphasized during her commencement speech to keep an eye out for challenges ahead by "looking around corners [and] throwing up every possible roadblock against hate, violence, and deception."

She added: "You might be thinking, given some of the issues Facebook has had, isn't what I'm saying hitting pretty close to home? Yes. It is."

Earlier this year, news surfaced that Cambridge Analytica, which had ties to President Donald Trump's campaign, may have accessed information on as many as 87 million Facebook users without the users' knowledge. The incident raised questions about whether Facebook does enough to protect user information.

Its issues don't stop there. Most recently, Facebook announced a bug caused 14 million of its users around the world to have their default sharing setting for all new posts set to "public"for a few days in May. Meanwhile, The New York Times reported on Sunday that Facebook shared personal data from its users with dozens of device makers, including Apple (AAPL) and Samsung (SSNLF).

Related: Facebook faces new regulatory backlash over data privacy

"It's painful when you miss something -- when you make the mistake of believing so much in the good you are seeing that you don't see the bad," she said.

Sandberg stressed the company will "see this through."

"It's not enough to be technologists -- we have to make sure that technology serves people," she said. "We are not indifferent creators -- we have a duty of care. And even when with the best of intentions you go astray -- as many of us have -- you have the responsibility to course correct."

Sandberg noted the "the fight to ensure tech is used for good is never over," a familiar sentiment also expressed by Facebook CEO Mark Zuckerberg. He previously said fighting bad actors is "an arms race" and a "never-ending battle" during a call with reporters in April.

She also touched on other issues, including the #MeToo movement and the significance of diversity in the workplace.

"Tools are shaped by the minds that make them and by the hands that use them," she said.

Related: Facebook bug set 14 million users' sharing settings to public

Sandberg has long advocated for helping women advance at work. She is the author of two books, "Lean In" and "Option B," each of which have corresponding nonprofit organizations.

LeanIn.org is dedicated to helping women achieve their goals in the workplace. OptionB.org aims to help individuals face adversity and cope with grief, something she was inspired to start after the sudden death of her husband due to cardiac arrhythmia in 2015.

Sandberg told graduates they can impact the workplace "from the day you enter it." She told an anecdote from her early career days about how two male teammates stepped up when her boss "belittled me very publicly."

That made all the difference for Sandberg.

"Even if you're the most junior person in the room, you have power," she said. "Use it. And use it well."