What was wrong: over SSH, set_vlan() put config["name"] into name "<name>" in config mode; the block is sent line by line, then write memory. A line break in the name ended the line and the switch ran the rest as commands; a double quote ended the name. netOrk replays VLAN names other devices reported (NetOrk/netork#2455), so a compromised device could set a manager password on the switch.
Fix:set_vlan() raises ValueError for a name, set_interface() for a description, containing \r, \n or ", before anything is sent, over every transport (as the SNMP writes already refuse such values). _cli_set_interface put the description into name "<desc>" the same way (second commit).
Tests:tests/unit/test_cli_values.py — the injected VLAN name and each character refused over SSH and REST with nothing sent, the same for a description (both red before their fix), a plain name and a one-line description still sent quoted, a VLAN without a name and an empty description still sent.
**What was wrong:** over SSH, `set_vlan()` put `config["name"]` into `name "<name>"` in config mode; the block is sent line by line, then `write memory`. A line break in the name ended the line and the switch ran the rest as commands; a double quote ended the name. netOrk replays VLAN names other devices reported (NetOrk/netork#2455), so a compromised device could set a manager password on the switch.
**Fix:** `set_vlan()` raises `ValueError` for a name, `set_interface()` for a description, containing `\r`, `\n` or `"`, before anything is sent, over every transport (as the SNMP writes already refuse such values). `_cli_set_interface` put the description into ` name "<desc>"` the same way (second commit).
**Tests:** `tests/unit/test_cli_values.py` — the injected VLAN name and each character refused over SSH and REST with nothing sent, the same for a description (both red before their fix), a plain name and a one-line description still sent quoted, a VLAN without a name and an empty description still sent.
Closes #28
Over SSH the name went into `name "<name>"` in config mode, one line of a
block sent line by line before `write memory`: a line break ended the
line and the switch ran the rest as commands, a double quote ended the
name. netOrk replays VLAN names other devices reported here
(NetOrk/netork#2455).
set_vlan() now raises ValueError for a name containing \r, \n or ",
before anything is sent, over every transport.
Over SSH the description went into ` name "<desc>"` under
`interface <port>`, one line of a block sent line by line before
`write memory`: a line break ran the rest as commands, a double quote
ended the value. It is the same injection as set_vlan's name
(NetOrk/netork#2455).
set_interface() now raises ValueError for a description containing \r,
\n or ", before anything is sent, over every transport, through the same
check as set_vlan (_check_cli_value). The tests move to
test_cli_values.py, which covers both.
The checks against line breaks and double quotes made procurve.py 20
lines longer than the quality ratchet allows (1365, recorded 1345). The
module-level ping parser moves to parsers.py, which holds every other
pure CLI parser, as parse_ping_output; its two result dicts become one
helper, so it is no longer over 50 lines. Behaviour is unchanged; tests
for an unreachable target and an unknown answer are added. The baseline
is lowered to what is measured now (procurve.py 1300, the ping entry
gone).
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
What was wrong: over SSH,
set_vlan()putconfig["name"]intoname "<name>"in config mode; the block is sent line by line, thenwrite memory. A line break in the name ended the line and the switch ran the rest as commands; a double quote ended the name. netOrk replays VLAN names other devices reported (NetOrk/netork#2455), so a compromised device could set a manager password on the switch.Fix:
set_vlan()raisesValueErrorfor a name,set_interface()for a description, containing\r,\nor", before anything is sent, over every transport (as the SNMP writes already refuse such values)._cli_set_interfaceput the description intoname "<desc>"the same way (second commit).Tests:
tests/unit/test_cli_values.py— the injected VLAN name and each character refused over SSH and REST with nothing sent, the same for a description (both red before their fix), a plain name and a one-line description still sent quoted, a VLAN without a name and an empty description still sent.Closes #28