Security
The server keeps the SSH keys encrypted and sends them only to collectors, through TLS.
The SSH keys
The server keeps the private key of each credential, encrypted with AES-256-GCM. The master key is in the variable SHELLGRAPH_KEY and never in the database. A stolen copy of the database does not give the SSH keys.
The UI never shows a key after you save it. Only the collector API sends a decrypted key, and only to a valid collector token. The server writes each of these requests to its log.
Why TLS is necessary
During a scan, the server sends the decrypted private key of the VLAN to the collector. Without TLS, any person who can read the network traffic gets the key. For this reason, the collector refuses an http:// server URL. The only exceptions are localhost and 127.0.0.1.
Collector tokens
A collector token can read the keys of all VLANs. The server keeps only the SHA-256 of each token, and the UI shows a token one time only. Make one token for each collector machine, so that you can revoke one machine without a change to the others.
The collector cannot run commands from the server
The collection script is in the collector binary. The server sends only data: the CIDR, the port and the credential. A person who takes control of the server still has no path to run a command on your servers through the collector.
The identity of a host
Each target host sends its machine ID and its hostname, and the server finds the host by these two values. A host under the control of an attacker can send the identity of another host. The SSH host key is the proof of the identity: the server keeps the key of each host from the first scan. A result with the identity of a known host and another host key gets the status hostkey_changed. The known host keeps its data and becomes stale.
If the change is correct (for example a new installation of the host), select Accept new host key on the host page.
Sessions
The session cookie is a random value, HttpOnly and SameSite=Strict. It is Secure when the server uses HTTPS or when the proxy sends X-Forwarded-Proto: https. The server keeps only the SHA-256 of the value. A logout deletes the session in the server, so a copy of the cookie does not work after it. The UI API rejects requests from other sites.
The server signs the cookie of the OIDC login with a secret that it makes from SHELLGRAPH_KEY. A stolen copy of the database does not give this secret.
After 10 wrong passwords in 15 minutes for one login, the LDAP login refuses that login until the 15 minutes end. The count is in the memory of one server instance. Also use the password policy of the directory.
The browser
Each answer has a Content-Security-Policy that lets the browser load scripts only from the server, and headers that stop other sites from showing the UI in a frame. On HTTPS, the server also sends Strict-Transport-Security.
The server does not read the X-Forwarded-Host header. Behind a reverse proxy that changes the host name, set SHELLGRAPH_PUBLIC_URL.
For the security of the target hosts, see Collector security.