Loose file permissions
File and directory permissions should be granted to specific users and groups. Granting permissions to wildcards, such as everyone or others, can lead to privilege escalations, leakage of sensitive information, and inadvertently running malicious code.
def change_file_permissions_noncompliant():
    import os
    import stat
    # Noncompliant: permissions assigned to all users.
    os.chmod("sample.txt", stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
def change_file_permissions_compliant():
    import os
    import stat
    # Compliant: permissions assigned to owner and owner group.
    os.chmod("sample.txt", stat.S_IRWXU | stat.S_IRWXG)