
HTTPS Protects Data in Transit, Not Your App: What the Padlock Really Means
- كاتب موثّق
محتويات المقال
http:// request, and passes its TLS scan. All of that is true. The request was encrypted all the way to the server. Then the server decrypted it, as it must, and wrote it to a log that half the company can search.
The common misconception
What actually happens
TLS secures the pipe between two endpoints
At the server, it's plaintext again
The certificate proves the domain, not the intentions
Even in transit, there are gaps to close
http:// request a user types, before your redirect, travels in the clear. fixes that for later visits: the header tells the browser to upgrade every future request to HTTPS on its own, and to refuse to let users click through certificate errors. MDN notes its one weakness: it "does not take effect until the browser has made at least one secure connection to the host", which the preload list addresses. Cookies need the Secure attribute, which OWASP says "instructs the browser to only send them over encrypted HTTPS connections." And a page served over HTTPS shouldn't load scripts over HTTP.
Where the password leaked
var builder = WebApplication.CreateBuilder(args);// "Safe to log everything: the traffic is encrypted"builder.Services.AddHttpLogging(o => o.LoggingFields = HttpLoggingFields.All);var app = builder.Build();app.UseHttpsRedirection();app.UseHttpLogging();app.MapPost("/signup", (SignupRequest req) => Results.Created());app.Run();var builder = WebApplication.CreateBuilder(args);builder.Services.AddHttpLogging(o => o.LoggingFields = HttpLoggingFields.RequestPropertiesAndHeaders | HttpLoggingFields.ResponseStatusCode); // metadata, never bodiesbuilder.Services.AddHsts(o => o.MaxAge = TimeSpan.FromDays(365));var app = builder.Build();if (!app.Environment.IsDevelopment()) app.UseHsts();app.UseHttpsRedirection();app.UseHttpLogging();app.MapPost("/signup", (SignupRequest req) => Results.Created());app.Run();info: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[1] Request: Method: POST Scheme: https Path: /signupinfo: Microsoft.AspNetCore.HttpLogging.HttpLoggingMiddleware[3] RequestBody: {"email":"mona@example.com","password":"Tr0ub4dor&3"}Scheme: https, and the password in the next line. Microsoft's own docs warn that "HTTP logging can potentially log personally identifiable information (PII)." The fixed version logs request metadata and the status code only; with the same request, the password appeared nowhere in the output. It also sends HSTS outside development, which Microsoft advises because "HSTS settings are highly cacheable by browsers".
http:// request before the redirect | ||
How to apply it in your project
Enforce HTTPS everywhere Redirect pages from HTTP and send HSTS from production. For APIs, Microsoft advises not listening on HTTP at all, or rejecting HTTP requests with a 400, because API clients may not follow redirects. Mark every cookie Secure Set the Secureattribute on session and auth cookies, so the browser never sends them over plain HTTP.Audit what happens after TLS ends Check request logging, exception handlers, error trackers and analytics. Log metadata, not bodies, and send Cache-Control: no-storeon responses with sensitive data, as OWASP recommends.Protect data at rest separately Decide which stored fields need encryption, who can read backups, and what you shouldn't store at all. Keep application security on the list HTTPS doesn't replace authentication, authorization or input handling. Review those on their own, request by request.
Key takeaways
HTTPS protects data between the browser and your server, against anyone on the network. At your server the data is plaintext; logs, caches, backups and code are outside TLS. A valid certificate proves control of a domain, not that the site is safe or honest. Close the transit gaps HTTPS leaves: HSTS, Secure cookies, no HTTP for APIs. Attacks like SQL injection and XSS travel inside HTTPS; secure code is still your job.
التعليقات (0)