Web TechnologiesCourse and practice

Secrets in the open

Why a password or a key shared where you can't tell who has read it counts as leaked, what to do the day it leaks, and how to give each person and each tool only the access its job needs.

6 parts · about 7 min

Present Cheat sheet

Where secrets leak

A password stays secret only while you know exactly who has it.

A secret is any value that gives access to an account: a password, a secret key, the login of an admin screen. It stays secret only while you know exactly who has it. That's the whole test.

Most secrets don't leak through hacking. They leak through ordinary tools that everyone uses every day:

  • A festival's ticketing password is pasted into the WhatsApp group of its 40 volunteers, "so that anyone can print the tickets tonight".
  • A dentist's booking software password is on a sticky note on the screen. The note appears in a photo of the new waiting room on the practice's Instagram.
  • A developer pastes a key into a ticket in the issue tracker, so that a colleague can test something.

In each case, nobody meant any harm, and nothing bad may have happened yet. But nobody can say any more who has the secret. Someone may have forwarded the message, taken a screenshot, or lost a phone with the chat on it. So the rule is simple: once you can't tell who has read a secret, treat it as leaked. The word for this is compromised.

Your portfolio has secrets too: the passwords of your hosting account, your domain name and your form service, and of the email account that receives all their messages. The same rule applies to them.

Cheat sheet

Secretsecret
a value that must stay private because it gives access to an account, such as a password or a key.
Credentialsidentifiants
the login and password, or the key, that let someone into an account.
Compromisedcompromis
describes a password or a key that people outside the planned list may have seen, so it must be treated as leaked.
Admin screenback-office
the private pages where a team edits a site's content, such as texts and images, without touching code.
Issue trackeroutil de suivi des tickets
a shared list of requests and bugs, with one item for each, such as GitHub Issues, Jira or Trello.
Hostinghébergement
the service that stores a site's files and sends them to visitors.
Domain namenom de domaine
the readable name of a website, such as leboncoin.fr, which its owner rents by the year.

Deleting it doesn't undo it

The usual reaction to a leak is to delete the message, the document or the file. It feels like a fix, but it isn't. Deleting removes the original from view. It doesn't touch the copies, and a message or a document starts making copies as soon as it exists.

A message in a group chat appears in a notification on every member's phone. It stays in the chat's search, and in each person's backups. Someone may have taken a screenshot or forwarded it. A shared document keeps its version history, and anyone who opened it may have downloaded it. A file in a code repository stays in the project's history. Git keeps every past version, so deleting the file today leaves it in yesterday's commit. Public repositories are worse: bots search them for passwords and keys all day, and find new ones within minutes.

So there is only one fix. Change the password, or revoke the key and create a new one. Then every old copy stops working, wherever it is. This is called rotating the secret. After that, update everything that uses it, such as the site's settings. Otherwise the site stops working too.

A password posted in a chat is copied at once, so only changing it makes every copy useless1. Copies that nobody can delete: notifications (a preview on every member's phone), the chat's search (anyone in the group can find it later), screenshots and forwards (copies sent to people outside the group), backups (each phone keeps a copy of the whole chat). 2. Deleting the message removes only the original. 3. Changing the password makes every copy stop working at once.A password in a chatPosted in a group of 40 volunteersCopies that nobody can deleteNotificationsA preview on every member's phoneThe chat's searchAnyone in the group can find it laterScreenshots and forwardsCopies sent to people outside thegroupBackupsEach phone keeps a copy of the wholechatDeleting it removes only this oneChange the passwordEvery copy stops working at once

Swipe sideways to see the whole figure.

Figure 1

Cheat sheet

Version historyhistorique des versions
the list of past versions that a document or a tool keeps, which anyone with access can open.
Historyhistorique
the list of every commit in a project, with what changed, why, who made it and when.
GitGit
the most common version control tool, which saves each change to a project as a commit.
Repositorydépôt
the project's folder, also called a repo, with all its files and the history of every saved change.
Botbot, robot
a program that visits sites or calls services by itself, sometimes thousands of times an hour.
Revokerévoquer
to cancel a key at the service, so that it stops working for anyone who has a copy.
Rotaterenouveler, faire une rotation
to replace a password or a key with a new one, so that every old copy stops working.

The day a secret leaks

A bike shop discovers that the password of its online shop's admin screen has been in the welcome guide of every seasonal worker since April. The guide is a PDF, sent by email to about twenty people. What now?

First, change the password today, before you investigate. Every hour that the old one works is an hour in which someone can use it. Then update everything that uses it, so that it keeps working with the new one.

Next, check for signs of use. Most services keep logs, a record of each login and action, with the time and where it came from. Ask whoever runs the service to check them for logins since April. Then activate two-factor authentication on that account, so that a password alone is no longer enough to log in.

Last, think about the data behind the password. The admin screen shows customers' names, addresses and orders. If someone may have read them, that's a personal data breach. Tell whoever handles GDPR in the company at once, because a breach may have to be reported to the CNIL within 72 hours.

If an agency or a freelancer exposed the secret, ask them to fix it before you sign the acceptance and pay the last invoice. After that, they have much less reason to hurry.

Cheat sheet

Logslogs, journaux
the record a server keeps of what it did, with the time of each action and any errors.
Two-factor authenticationauthentification à deux facteurs, 2FA
a login that asks for a second proof, such as a code on your phone, as well as the password.
Personal data breachviolation de données personnelles
a leak, loss or change of personal data, which may have to be reported to the CNIL within 72 hours.
CNILCNIL
the French authority for personal data, which receives reports of breaches and can fine organisations.
GDPRRGPD
the European law on personal data, which applies as soon as a site collects a name or an email.
Sign-offvalidation
a written approval that one part of the work is accepted, so the next part can start.

Where secrets belong

Secrets need a proper home, where each one is shared with named people and you can see who has what.

For passwords, that home is a password manager, such as Bitwarden, 1Password or Dashlane. It keeps each password encrypted and shares it only with the people you choose. You can remove someone in one click. For the keys that a site's code uses, the home is the hosting service's secret settings. The code reads them there, and nobody has to paste them anywhere. On your computer, your agent keeps them in a .env file, which never goes into the repository.

Better still, avoid shared passwords. When each person has their own account on each service, you can remove one person the day they leave, without changing everyone's password. And the logs show who did what. A shared account hides that.

Then activate two-factor authentication on the accounts that matter most: hosting, domain, payments and email. The email account matters most of all, because whoever reads your email can reset most of your other passwords.

The example below shows two welcome emails for a new volunteer on a theatre's web team. The first one gives the same password for everything, and asks the volunteer to forward it. The second one gives the volunteer their own invitations, and says where the shared passwords are kept.

One password, forwarded to everyone

Code
The welcome email
Welcome to the web team!
Here are the accesses:
Hosting: admin / Lumiere2024!
Domain: admin / Lumiere2024!
Admin screen: admin / Lumiere2024!
It's the same everywhere.
Forward this to anyone
who needs it.

An account for each person

Code
The welcome email
Welcome to the web team!
You'll receive two invitations:
- the admin screen, as an editor
- the theatre's password manager
Activate two-factor authentication
when you accept them.
Hosting and domain: ask Anna or
Marc, who are the two admins.
Never send a password by email.
Example 1Two welcome emails for a new volunteer on a theatre's web team

Cheat sheet

Password managergestionnaire de mots de passe
an app that stores passwords encrypted and shares each one only with the people you choose, such as Bitwarden.
Environment variablevariable d'environnement
a value, such as a key, that the code reads from the computer it runs on.
.env filefichier .env
a file on your computer that holds the project's environment variables and must never be committed.
Shared accountcompte partagé
one login used by several people, so nobody can tell who did what or remove one person's access.
Two-factor authenticationauthentification à deux facteurs, 2FA
a login that asks for a second proof, such as a code on your phone, as well as the password.
Logslogs, journaux
the record a server keeps of what it did, with the time of each action and any errors.

Only the access the job needs

Hiding a secret is only half the job. The other half is limiting what it can do. Every password and every key allows a set of actions: reading data, adding it, changing it, deleting it, managing other accounts. The right access allows only what the task needs, for as long as it needs it. This principle is called least privilege.

Take a museum's website. A photographer adds pictures of the new exhibition, so she needs an account that can add images. She doesn't need one that can delete pages or invite other users. A translator needs to edit the English pages, not the shop's prices. A newsletter tool needs to add subscribers to a list, not to read the whole customer database. The accountant needs to read the shop's invoices, not to change them: that's read-only access.

Nobody here is dishonest, and that's not the point. Honest people make mistakes, get their own accounts hacked, or lose a laptop. An AI agent can misunderstand an instruction. With the smallest access, the worst case stays small. Your own coding agent needs your portfolio's folder, not the password of your email.

Most services offer roles for this, such as viewer, editor and admin. Give the admin role to two or three people only, and protect it with two-factor authentication. Separate, limited accesses can also be removed one at a time, the day a contract ends.

What each access allows: an admin account allows everything, and each job needs only a few actions1. An admin account (it can do everything, so a mistake can too): read, add, change, delete, manage other accounts. 2. The photographer (adds pictures of the new exhibition): read, add. 3. The translator (edits the english pages): read, change. 4. The newsletter tool (adds new subscribers to a list): add. 5. The accountant (reads the shop's invoices): read.ReadAddChangeDeleteManage otheraccountsAllowedNot allowedAn admin accountIt can do everything, so a mistake can tooThe photographerAdds pictures of the new exhibitionThe translatorEdits the English pagesThe newsletter toolAdds new subscribers to a listThe accountantReads the shop's invoices

Swipe sideways to see the whole figure.

Figure 2

Cheat sheet

Least privilegeprincipe du moindre privilège
the rule that every person and every tool gets only the access its job needs, for as long as it needs it.
Rolerôle
a set of permissions in a service, such as viewer, editor or admin, given to each account.
Adminadministrateur
the role that can do everything in a service, including adding and removing other accounts.
Read-only accessaccès en lecture seule
an access that lets you see data, but not change or delete it.
AI agentagent d'IA
a program that reads and writes a project's files and runs commands, following your requests in a chat.
Two-factor authenticationauthentification à deux facteurs, 2FA
a login that asks for a second proof, such as a code on your phone, as well as the password.

What to ask

Ask these questions at the start of a project, at every handover, and whenever someone asks for access.

Ask the team, the agency or the freelancer where the passwords and keys live, and who can read them. You want to hear "in a password manager" and "in the hosting's secret settings", with a list of names. If a secret was ever in a document, a chat, an email or the code, ask whether it has been changed since. "We deleted it" is not an answer. If you're about to accept a delivery, ask for this before you sign.

When someone asks for access, whether a colleague, an agency, a tool or an AI agent, don't simply say yes or no. Ask what exactly it needs to do, and for how long. Then give the narrowest role that does the job, straight away, so that the work isn't blocked. Write down who has what, and remove it when the job ends.

For your portfolio, check three things today. Is two-factor authentication active on your email, your hosting and your domain? Is a key anywhere in your repository, in any past version? And does your agent have more access than it needs?

Cheat sheet

Password managergestionnaire de mots de passe
an app that stores passwords encrypted and shares each one only with the people you choose, such as Bitwarden.
Rotaterenouveler, faire une rotation
to replace a password or a key with a new one, so that every old copy stops working.
Least privilegeprincipe du moindre privilège
the rule that every person and every tool gets only the access its job needs, for as long as it needs it.
Rolerôle
a set of permissions in a service, such as viewer, editor or admin, given to each account.
Adminadministrateur
the role that can do everything in a service, including adding and removing other accounts.
Two-factor authenticationauthentification à deux facteurs, 2FA
a login that asks for a second proof, such as a code on your phone, as well as the password.
Handoverpassation
the moment when the builders give the site, its accounts and its documents to the client.

Practise this strand

These questions put you in the situations this lesson describes. You answer in your own words, and you get a level, feedback and a full answer.