Security and professional ethics
Introducido
6:03
Ingeniería de software
Software engineering is how systems outlive their authors. The first three units shape the product: requirements, architecture and interface design. The next…
Narración en inglés · subtítulos en inglés y 中文 que puedes cambiar
En esta lección
| English | Significado |
|---|---|
| threat model/θret ˈmɒdl/ | modelo de amenazas |
| entry point | |
| mitigation/ˌmɪtɪˈɡeɪʃn/ | a measure that reduces a risk |
| authorisation matrix/ˌɔːθəraɪˈzeɪʃn ˈmeɪtrɪks/ | a table of which roles may perform which actions |
| parameterised query/ˌpærəˈmetəraɪzd ˈkwɪərɪ/ | A database query whose data values are supplied separately as parameters rather than inserted into its command text. |
| authorisation/ˌɔːθəraɪˈzeɪʃn/ | The granting or checking of permission to access a resource or perform an action. |
| revoke and rotate/rɪˈvəʊk ænd rəʊˈteɪt/ | cancel a leaked secret and replace it with a new one |
| Defence in depth/dɪˈfens ɪn depθ/ | several independent layers of protection, so one failure is not enough |
| salted/ˈsɒltɪd/ | (of a password hash) combined with a random value before hashing, so equal passwords give different hashes |
| salt/sɒlt/ | A value combined with a password or other input before hashing so identical inputs need not produce identical stored hashes. |
Activos, puntos de entrada, atacantes
- Un modelo de amenazas enumera activos (registros de miembros, historial de préstamos), puntos de entrada (formulario web, API, canal de recordatorios), atacantes (oportunistas, internos, automatizados) — luego empareja cada amenaza con una mitigación.


A threat model pairs —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Assets x entry points x attackers, then a mitigation per threat.
Put the steps of building a threat model in order.
Dificultad 3/5 · 200 monedas + un pequeño bono en el primer intento de hoy
You cannot judge an entry point until you know what it leads to, and a mitigation without a test is only a hope.
Privilegio mínimo, contado
- Matriz de autorización de BookShare: 3 roles x 6 acciones = 18 celdas, 4 permitidas — 14 denegaciones por defecto. Privilegio mínimo como propiedad contable.
- El formulario de búsqueda cierra su fila de inyección SQL con consultas parametrizadas y un límite de longitud — probado alimentando
' OR '1'='1y asegurando cero filas filtradas.
The authorisation matrix allows — of 18 cells
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
3 roles x 6 actions, 4 allowed: 14 denials by default.
El llamado ético
- El propietario del producto pide vender el historial de lectura a anunciantes. Los códigos profesionales priorizan el daño a la privacidad e interés público sobre la preferencia del empleador: rechazo documentado con alternativas (agregados anonimizados con consentimiento) — la ética es una decisión con registro escrito, no un sentimiento.
- "Herramienta interna" no es una exención de seguridad; la autorización ocultando enlaces falla porque el endpoint aún responde.
Why does a parameterised query stop the input ' OR '1'='1 from leaking every row?
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
The SQL text is fixed; the input fills the ? only as data. So ' OR '1'='1 is just a strange name that matches no member.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
The ethics call
- The product owner asks to sell members' reading history to advertisers. The professional codes put privacy harm and the public interest above what the employer prefers.
- The answer is a written refusal that offers alternatives (anonymised totals, with consent). Ethics is a decision with a written record, not a feeling.
- "It's an internal tool" is not a reason to skip security. Hiding a link is not authorisation 授权, because the page behind it still answers.
The professional answer to the data-sale request is —
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Codes put privacy and public interest above employer preference - the paper trail is the point.
Hiding the admin link from ordinary members stops them reaching the admin pages.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
The endpoint still answers anyone who types its address. Authorisation must be checked on the server for every request.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Secrets and dependencies
- A secret committed to git stays in the history even after a later commit deletes the file. The fix is to revoke and rotate 吊销并更换 the key at once, then clean the history. Keep secrets in environment variables or a vault, and scan commits for keys before they are pushed.
- Most code is other people's code. Pin dependency versions, keep a list of every component (a software bill of materials), and scan it for known weaknesses.
- Defence in depth 纵深防御 layers several controls, such as input checks, least privilege and logging, so one failure does not become a breach.
Deleting a leaked key file in a new commit removes the key from the repository's history.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Every earlier commit still contains it; rotate the key, then rewrite or purge the history.
An API key is found in a public repository. What comes first?
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
Assume it is already copied: only revoking it stops misuse.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Storing passwords
A per-user salt defeats precomputed hash tables.
Dificultad 1/5 · 100 monedas + un pequeño bono en el primer intento de hoy
A table would be needed for every salt value.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Storing passwords
- Never store passwords, only a salted 加盐 slow hash. The salt is random for each user: it makes tables computed in advance useless and gives equal passwords different hashes.
- A slow hash such as bcrypt or Argon2 has a work factor. At cost 12, bcrypt runs $2^{12}$ rounds, so each guess costs the attacker milliseconds instead of nanoseconds.
Todo $26^8$ lowercase eight-letter passwords at $10^{10}$ hashes a second: time (nearest second)?
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
$2.09 \times 10^{11}/10^{10} \approx 21$ s.
The same search at $10^4$ bcrypt guesses a second: time (nearest day)?
Dificultad 2/5 · 140 monedas + un pequeño bono en el primer intento de hoy
$2.09 \times 10^7$ s $/86\,400 \approx 242$ days.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Worked example: guessing eight lowercase letters
- There are $26^8 \approx 2.09 \times 10^{11}$ such passwords. A GPU computing $10^{10}$ fast hashes a second tries them all in about $\mathbf{21}$ s.
- At $10^4$ bcrypt guesses a second it needs $2.09 \times 10^7$ s, about 242 days, for one account, and the salt 盐值 means the attacker must start again for each account. Longer passwords help more: each extra letter multiplies the work by 26.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Marks that slip away
- "Internal" as an exemption. An internal tool is still an entry point 入口点.
- A secret in the repository. A committed key stays in the history for ever: rotate it and keep secrets in a secret store.
- SQL built from strings.
' OR '1'='1returns every row; use parameters.
Esta tarjeta es nueva, por eso aparece en inglés hasta que su traducción esté lista.
Recap
- A threat model pairs each asset and entry point with a mitigation:
| Threat | Mitigation |
|---|---|
SQL injection: ' OR '1'='1 |
parameterised queries |
| A hidden admin link | a server-side check on every request |
| A secret committed to git | revoke and rotate 吊销并更换 the key, then clean the history |
| Stolen passwords | salted, slow hashes |
- Least privilege can be counted: $18$ cells, $4$ allowed, $14$ denied by default.
- Ethics is a decision with a written record; hiding a link is not authorisation.
¿Qué salió mal? Solo el equipo del sitio ve esta información.