-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Remove sensitive password logging #931
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
04afdda
b536131
77d0d07
b1af704
519ee01
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -52,6 +52,8 @@ export const createApp = async (options: CreateAppOptions): Promise<{ | |
return cookies; | ||
}; | ||
|
||
const basicAuthString = "Basic " + new Buffer("user:" + options.password).toString("base64"); | ||
|
||
const ensureAuthed = (req: http.IncomingMessage, res: express.Response): boolean => { | ||
if (!isAuthed(req)) { | ||
res.status(401); | ||
|
@@ -94,7 +96,6 @@ export const createApp = async (options: CreateAppOptions): Promise<{ | |
userAgent = userAgent.join(", "); | ||
} | ||
logger.info("Failed login attempt", | ||
field("password", cookies.password), | ||
field("remote_address", remoteAddress(req)), | ||
field("user_agent", userAgent), | ||
field("timestamp", timestamp)); | ||
|
@@ -104,6 +105,10 @@ export const createApp = async (options: CreateAppOptions): Promise<{ | |
|
||
return true; | ||
} | ||
|
||
if (req.headers["authorization"] === basicAuthString) { | ||
return true; | ||
} | ||
} catch (ex) { | ||
logger.error("Failed to parse cookies", field("error", ex)); | ||
} | ||
|
@@ -137,9 +142,18 @@ export const createApp = async (options: CreateAppOptions): Promise<{ | |
|
||
if (!fs.existsSync(selfSignedKeyPath) || !fs.existsSync(selfSignedCertPath)) { | ||
try { | ||
let altNames: string[] = []; | ||
let networkInterfaces = os.networkInterfaces(); | ||
for(let ifName of Object.keys(networkInterfaces)){ | ||
let interfaces = networkInterfaces[ifName]; | ||
interfaces.filter(i => !i.internal && i.family === "IPv4").forEach(i => { | ||
altNames.push(i.address); | ||
}); | ||
} | ||
const certs = await new Promise<pem.CertificateCreationResult>((res, rej): void => { | ||
pem.createCertificate({ | ||
selfSigned: true, | ||
altNames: altNames | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I don't think this should be automatic. Since the certificate is self signed, your computer won't trust alt names anyway. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If you decide to trust the self-sigend certificate, the hostname/ip of the certificate still has to match in order to pass for a secure TLS connection. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Are you positive? We've been using this for a while now without any alt names and no issues have been reported. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm running this behind a proxy (on a different server) which reëncrypts the connection to code-server. The proxy trusts the self-signed certificate of code-server. But it is failing on the hostname verification, because the external ip of code-server is not matching the "localhost" which is in the certificate. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's dangerous imo as you can get MITMed easily with a self signed certificate. It's best you generate the certificate yourself and add it as a trusted certificate to the proxy or use HTTP and move code-server onto the proxy server. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I guess my same reasoning applies in general to code-server generating self signed certificates. 🤔 |
||
}, (err, result) => { | ||
if (err) { | ||
rej(err); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it'd be ok to log the hash of the password versus the expected hash. See #952
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is ok, but it wouldn't add any information other than "it doesn't match". Therefor it will only make the logs unreadable.