Your suspicions are true, 777 in
/opt isn't safe. Did you change the permissions recursively (with
-R flag)? If you changed the permissions without
-R flag you can revert it easily, but if you modified it recursively, all your directories and subdirectories in
/opt have the same permissions (777), so to revert it, it's necessary to do it manually.
Carlos R. Hernández