الانتقال إلى المحتوى
الأمان (Security)Secure Coding· 7 دقائق للقراءة

HTTPS Protects Data in Transit, Not Your App: What the Padlock Really Means

TLS keeps the network from reading or changing traffic. At your server the data is plaintext again, and everything after that is your job.

ReadIn

مقال كل يوم يفرق معاك

21 نوفمبر 2026
  • كاتب موثّق
محتويات المقال

A support engineer searches the logs for a failed sign-up and finds the user's password, in plain text, inside the request body the API logs for debugging. The team is surprised, because the site has a valid certificate, redirects every 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

The belief: if a site uses HTTPS, its users' data is secure. The padlock is on, so the job is done.

It's an easy belief, because HTTPS solves a real and serious problem. Browsers show a padlock for HTTPS, privacy pages promise bank-grade encryption, and compliance checklists ask whether traffic is encrypted. On a page served over plain HTTP, anyone on the same café Wi-Fi could read your session cookie. Fixing that feels like fixing security. But HTTPS protects one stretch of the journey, and data spends most of its life somewhere else.

What actually happens

TLS secures the pipe between two endpoints

HTTPS is HTTP over . RFC 8446, which defines TLS 1.3, lists what the secure channel provides: the server is always authenticated, the data is confidential, and it "cannot be modified by attackers without detection." The confidentiality promise is precise: "Data sent over the channel after establishment is only visible to the endpoints." And it holds "even in the face of an attacker who has complete control of the network."

That's a strong guarantee against everyone in the middle: the Wi-Fi owner, the ISP, a compromised router. Note the last word, though. The endpoints see everything, and one of them is your server.

At the server, it's plaintext again

OWASP's Transport Layer Security Cheat Sheet puts it in one sentence: "Although TLS provides protection of data while it is in transit, it does not provide any protection for data once it has reached the requesting system." From that point, the data is only as safe as your code. A log line, an error report sent to a third-party tracker, an unencrypted backup, a shared cache: none of them knows the request ever had a padlock.

The same goes for attacks. A SQL injection or an XSS payload arrives inside an encrypted request just as easily as a normal one, because the attacker has a valid TLS session like any other user. Those bugs get their own articles in this path.

The certificate proves the domain, not the intentions

The padlock means the browser verified a certificate for the name in the address bar. OWASP explains what that proof is worth: every public certificate is domain validated, which "involves practical proof of control of the name." A phishing site on a look-alike domain can get a valid certificate the same way you did. And TLS authenticates the server only: OWASP notes that "the identity of the client is not verified unless client certificates are employed." Knowing who the user is remains your login's job.

Even in transit, there are gaps to close

HTTPS only protects requests that actually use it. The first 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

C# Program.cs
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();

We ran the wrong version and sent a sign-up over HTTPS with a test password. An excerpt of what the log received:

text
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".

ThreatDoes HTTPS stop it?What does
Someone on the network reads the trafficYesTLS confidentiality
Someone on the network changes a pageYesTLS integrity
The first http:// request before the redirectNoHSTS and preloading
Secrets in logs, caches or backupsNoWhat you log and store
A phishing site with its own certificateNoUsers checking the domain, not the padlock
SQL injection, XSS, broken access controlNoSecure code

How to apply it in your project

  1. Enforce HTTPS everywhereRedirect 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.
  2. Mark every cookie SecureSet the Secure attribute on session and auth cookies, so the browser never sends them over plain HTTP.
  3. Audit what happens after TLS endsCheck request logging, exception handlers, error trackers and analytics. Log metadata, not bodies, and send Cache-Control: no-store on responses with sensitive data, as OWASP recommends.
  4. Protect data at rest separatelyDecide which stored fields need encryption, who can read backups, and what you shouldn't store at all.
  5. Keep application security on the listHTTPS 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.

📚 المصادر

  1. RFC 8446: The Transport Layer Security (TLS) Protocol Version 1.3
  2. Transport Layer Security Cheat Sheet — OWASP Cheat Sheet Series
  3. Strict-Transport-Security header — MDN Web Docs
  4. Enforce HTTPS in ASP.NET Core — Microsoft Learn
  5. HTTP logging in ASP.NET Core — Microsoft Learn

التعليقات (0)