---
source: crates/ruff_linter/src/rules/flake8_bandit/mod.rs
---
S103 `os.chmod` setting a permissive mask `0o227` on file or directory
 --> S103.py:6:25
  |
4 | keyfile = "foo"
5 |
6 | os.chmod("/etc/passwd", 0o227)  # Error
  |                         ^^^^^
7 | os.chmod("/etc/passwd", 0o7)  # Error
8 | os.chmod("/etc/passwd", 0o664)  # OK (stable); Error (preview, S_IWGRP)
  |

S103 `os.chmod` setting a permissive mask `0o7` on file or directory
 --> S103.py:7:25
  |
6 | os.chmod("/etc/passwd", 0o227)  # Error
7 | os.chmod("/etc/passwd", 0o7)  # Error
  |                         ^^^
8 | os.chmod("/etc/passwd", 0o664)  # OK (stable); Error (preview, S_IWGRP)
9 | os.chmod("/etc/passwd", 0o777)  # Error
  |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:9:25
   |
 7 | os.chmod("/etc/passwd", 0o7)  # Error
 8 | os.chmod("/etc/passwd", 0o664)  # OK (stable); Error (preview, S_IWGRP)
 9 | os.chmod("/etc/passwd", 0o777)  # Error
   |                         ^^^^^
10 | os.chmod("/etc/passwd", 0o770)  # Error
11 | os.chmod("/etc/passwd", 0o776)  # Error
   |

S103 `os.chmod` setting a permissive mask `0o770` on file or directory
  --> S103.py:10:25
   |
 8 | os.chmod("/etc/passwd", 0o664)  # OK (stable); Error (preview, S_IWGRP)
 9 | os.chmod("/etc/passwd", 0o777)  # Error
10 | os.chmod("/etc/passwd", 0o770)  # Error
   |                         ^^^^^
11 | os.chmod("/etc/passwd", 0o776)  # Error
12 | os.chmod("/etc/passwd", 0o760)  # OK (stable); Error (preview, S_IWGRP)
   |

S103 `os.chmod` setting a permissive mask `0o776` on file or directory
  --> S103.py:11:25
   |
 9 | os.chmod("/etc/passwd", 0o777)  # Error
10 | os.chmod("/etc/passwd", 0o770)  # Error
11 | os.chmod("/etc/passwd", 0o776)  # Error
   |                         ^^^^^
12 | os.chmod("/etc/passwd", 0o760)  # OK (stable); Error (preview, S_IWGRP)
13 | os.chmod("~/.bashrc", 511)  # Error
   |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:13:23
   |
11 | os.chmod("/etc/passwd", 0o776)  # Error
12 | os.chmod("/etc/passwd", 0o760)  # OK (stable); Error (preview, S_IWGRP)
13 | os.chmod("~/.bashrc", 511)  # Error
   |                       ^^^
14 | os.chmod("/etc/hosts", 0o777)  # Error
15 | os.chmod("/tmp/oh_hai", 0x1FF)  # Error
   |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:14:24
   |
12 | os.chmod("/etc/passwd", 0o760)  # OK (stable); Error (preview, S_IWGRP)
13 | os.chmod("~/.bashrc", 511)  # Error
14 | os.chmod("/etc/hosts", 0o777)  # Error
   |                        ^^^^^
15 | os.chmod("/tmp/oh_hai", 0x1FF)  # Error
16 | os.chmod("/etc/passwd", stat.S_IRWXU)  # OK
   |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:15:25
   |
13 | os.chmod("~/.bashrc", 511)  # Error
14 | os.chmod("/etc/hosts", 0o777)  # Error
15 | os.chmod("/tmp/oh_hai", 0x1FF)  # Error
   |                         ^^^^^
16 | os.chmod("/etc/passwd", stat.S_IRWXU)  # OK
17 | os.chmod(keyfile, 0o777)  # Error
   |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:17:19
   |
15 | os.chmod("/tmp/oh_hai", 0x1FF)  # Error
16 | os.chmod("/etc/passwd", stat.S_IRWXU)  # OK
17 | os.chmod(keyfile, 0o777)  # Error
   |                   ^^^^^
18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700)  # Error
19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU)  # Error
   |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:18:19
   |
16 | os.chmod("/etc/passwd", stat.S_IRWXU)  # OK
17 | os.chmod(keyfile, 0o777)  # Error
18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700)  # Error
   |                   ^^^^^^^^^^^^^^^^^^
19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU)  # Error
20 | os.chmod("~/hidden_exec", stat.S_IXGRP)  # Error
   |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:19:19
   |
17 | os.chmod(keyfile, 0o777)  # Error
18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700)  # Error
19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU)  # Error
   |                   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
20 | os.chmod("~/hidden_exec", stat.S_IXGRP)  # Error
21 | os.chmod("~/hidden_exec", stat.S_IXOTH)  # OK (stable); Error (preview, S_IXOTH)
   |

S103 `os.chmod` setting a permissive mask `0o10` on file or directory
  --> S103.py:20:27
   |
18 | os.chmod(keyfile, 0o7 | 0o70 | 0o700)  # Error
19 | os.chmod(keyfile, stat.S_IRWXO | stat.S_IRWXG | stat.S_IRWXU)  # Error
20 | os.chmod("~/hidden_exec", stat.S_IXGRP)  # Error
   |                           ^^^^^^^^^^^^
21 | os.chmod("~/hidden_exec", stat.S_IXOTH)  # OK (stable); Error (preview, S_IXOTH)
22 | os.chmod("/etc/passwd", stat.S_IWOTH)  # Error
   |

S103 `os.chmod` setting a permissive mask `0o2` on file or directory
  --> S103.py:22:25
   |
20 | os.chmod("~/hidden_exec", stat.S_IXGRP)  # Error
21 | os.chmod("~/hidden_exec", stat.S_IXOTH)  # OK (stable); Error (preview, S_IXOTH)
22 | os.chmod("/etc/passwd", stat.S_IWOTH)  # Error
   |                         ^^^^^^^^^^^^
23 | os.chmod("/etc/passwd", 0o100000000)  # Error
   |

S103 `os.chmod` setting an invalid mask on file or directory
  --> S103.py:23:25
   |
21 | os.chmod("~/hidden_exec", stat.S_IXOTH)  # OK (stable); Error (preview, S_IXOTH)
22 | os.chmod("/etc/passwd", stat.S_IWOTH)  # Error
23 | os.chmod("/etc/passwd", 0o100000000)  # Error
   |                         ^^^^^^^^^^^
24 |
25 | # https://github.com/astral-sh/ruff/issues/18863
   |

S103 `os.chmod` setting a permissive mask `0o11` on file or directory
  --> S103.py:27:30
   |
25 | # https://github.com/astral-sh/ruff/issues/18863
26 | os.chmod("/etc/secrets.txt", 0o21)  # OK (stable); Error (preview, S_IWGRP)
27 | os.chmod("/etc/secrets.txt", 0o11)  # Error (S_IXGRP)
   |                              ^^^^
   |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:31:20
   |
30 | def f(path, mode):
31 |     os.chmod(path, mode | 0o777)  # Error (statically-known dangerous bits)
   |                    ^^^^^^^^^^^^
32 |     os.chmod(path, mode | 0o700)  # OK (no dangerous bits in known-set)
33 |     os.chmod(path, mode & 0o700)  # OK (no bits known to be set)
   |

S103 `os.chmod` setting a permissive mask `0o777` on file or directory
  --> S103.py:37:30
   |
36 | os.chmod("/etc/secrets.txt", 0o777777 & 0o700)  # OK (partial-AND cancels out-of-range)
37 | os.chmod("/etc/secrets.txt", 0o777777 & 0o777)  # Error
   |                              ^^^^^^^^^^^^^^^^
38 | os.chmod("/etc/passwd", 0o200000)  # Error (bit outside 0o7777)
   |

S103 `os.chmod` setting an invalid mask on file or directory
  --> S103.py:38:25
   |
36 | os.chmod("/etc/secrets.txt", 0o777777 & 0o700)  # OK (partial-AND cancels out-of-range)
37 | os.chmod("/etc/secrets.txt", 0o777777 & 0o777)  # Error
38 | os.chmod("/etc/passwd", 0o200000)  # Error (bit outside 0o7777)
   |                         ^^^^^^^^
39 |
40 | os.chmod("/etc/passwd", 99999999999999999999999)  # Error (oversized)
   |

S103 `os.chmod` setting an invalid mask on file or directory
  --> S103.py:40:25
   |
38 | os.chmod("/etc/passwd", 0o200000)  # Error (bit outside 0o7777)
39 |
40 | os.chmod("/etc/passwd", 99999999999999999999999)  # Error (oversized)
   |                         ^^^^^^^^^^^^^^^^^^^^^^^
41 | os.chmod("/etc/passwd", 99999999999999999999999 & 0o200000)  # OK
42 | os.chmod("/etc/passwd", 99999999999999999999999 | 0o777)  # Error (oversized)
   |

S103 `os.chmod` setting an invalid mask on file or directory
  --> S103.py:42:25
   |
40 | os.chmod("/etc/passwd", 99999999999999999999999)  # Error (oversized)
41 | os.chmod("/etc/passwd", 99999999999999999999999 & 0o200000)  # OK
42 | os.chmod("/etc/passwd", 99999999999999999999999 | 0o777)  # Error (oversized)
   |                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43 |
44 | os.chmod("/tmp/x", 18446744073709551616 ^ 18446744073709551616)  # OK (both sides identical)
   |
