Skip to content
Tutorials Center
My learning

Topics

Lesson 41 of 50 ยท Management, Risk and Professional Practice

Ethics, Security and Licensing

Learn professional ethics, privacy, the secure development life cycle, STRIDE threat modeling and open source license basics, with JavaScript stand-ins.

Software engineers decide things that affect real people: what data is collected, who can see it, what happens when the system fails, and whose code they are allowed to reuse. These decisions are not only technical. This lesson covers three connected parts of professional practice: ethics (what you owe to users and society), security (building systems that resist misuse), and licensing (the legal terms under which software is shared).

None of this can be run on the site as real tooling, so the standards, license texts and security processes are described in plain text. The runnable examples are JavaScript stand-ins: a license compatibility checker and a threat-modeling question generator. They are simplified teaching models. They are not legal advice, and real license decisions need a qualified person, because the details depend on how software is combined, distributed and used.

Professional ethics

Engineers in other fields are bound by professional codes. Software has its own. The best known is the ACM Code of Ethics and Professional Conduct, and an earlier joint statement by ACM and the IEEE Computer Society, the Software Engineering Code of Ethics and Professional Practice, covers similar ground in eight principles about the public, clients and employers, the product, judgment, management, the profession, colleagues and oneself. In paraphrase, the ideas that matter most day to day are:

  • Public interest first. When the interests of an employer and the safety or well-being of the public conflict, the public comes first.
  • Avoid harm. Think about who could be hurt by a failure, a misuse or an unfair outcome, including people who never use the product directly.
  • Be honest. Do not claim abilities you lack, hide known defects, or give estimates you know are unrealistic. Report problems early.
  • Be fair. Take care that systems do not discriminate, for example through biased data or inaccessible design.
  • Respect privacy and confidentiality. Collect and keep only what is needed, and protect it.
  • Respect others' work. Give credit, follow license terms and do not pass off other people's code or ideas as your own.
  • Keep your skills current and maintain quality. Competence is an ethical duty when others rely on your work.

Ethics shows up in ordinary moments rather than dramatic ones. Your manager asks you to ship with a known security flaw to meet a date. A feature quietly tracks users in a way they would not expect. A test result is rounded up for a report. Practical habits help: raise concerns in writing, propose an alternative rather than only objecting, escalate if the risk is serious, and keep a record of what was decided and by whom. A blameless culture (see working in a team) makes it safer to speak up.

Privacy by design

Privacy is the right of people to control information about themselves. Laws such as the EU's GDPR and many national and state laws set legal minimums, but the engineering habits are simple enough to apply on any project:

  • Data minimization: do not collect what you do not need. Data you never stored cannot leak.
  • Purpose limitation: use data only for the reason you gave when collecting it.
  • Retention limits: delete data when its purpose ends, and make deletion actually work, including backups and copies.
  • Access control: give each person and each service the least access it needs.
  • Protection: encrypt sensitive data in transit and at rest, and never log secrets or personal data by accident.
  • Transparency and consent: tell users in plain language what you collect and let them choose where the law or good practice requires it.

Privacy is much cheaper to design in at the start than to bolt on after a breach, which is why it appears in the requirements as a non-functional requirement and in architecture reviews, not only at the end.

Security across the life cycle

A common mistake is to treat security as a final test: build the system, then hire someone to try to break it. By then the major weaknesses are baked into the design, and fixing them is slow and expensive. A secure software development life cycle (secure SDLC) adds security work to every phase of the life cycle, the same "shift left" idea that applies to defects in general.

Security in every phase

Requirements Name security and privacy needs.
Design Threat model the architecture.
Code Secure coding rules and review.
Test Static analysis and security tests.

Each phase gets its own security task, not one big test at the end.

1 / 2

Typical secure-SDLC activities, phase by phase:

  • Requirements: list what must be protected and from whom; add requirements such as "passwords are stored only as salted hashes" or "all personal data is deleted within 30 days of account closure".
  • Design: threat modeling (below), least privilege, defense in depth (several independent layers, so one failure is not fatal), and secure defaults.
  • Implementation: validate all input, encode all output, use well-reviewed libraries for cryptography rather than writing your own, keep secrets out of source control (see configuration management), and review code for security issues.
  • Testing: static analysis, dependency scanning for known vulnerabilities, security-focused test cases, and sometimes a penetration test by outsiders.
  • Deployment and maintenance: harden configuration, monitor, and keep third-party components up to date, since most applications consist mostly of other people's code.

Three principles recur everywhere. Least privilege: each user, process and service gets only the access it needs. Defense in depth: assume any single control can fail. Fail securely: when something breaks, the system should deny access, not grant it. Security is also about trade-offs with other software qualities, such as usability and performance, which is why it needs explicit requirements and not just good intentions.

Threat modeling basics

Threat modeling is structured thinking about how a system could be attacked, done early enough to change the design. A simple method has four steps, often phrased as four questions: What are we building? What can go wrong? What will we do about it? Did we do a good job?

  1. Model the system. Draw a data flow diagram: external entities (users, other systems), processes, data stores and data flows, with trust boundaries (lines where data passes between zones of different trust, such as the internet and your servers).
  2. Find threats. For each element, ask what could go wrong. A popular mnemonic is STRIDE: Spoofing (pretending to be someone else), Tampering (changing data), Repudiation (denying an action), Information disclosure (leaking data), Denial of service (making the system unavailable), Elevation of privilege (gaining rights you should not have).
  3. Decide what to do. For each threat: mitigate it, remove the feature, transfer the risk (for example with insurance or a provider), or accept it knowingly. Record the decision, as in the risk register.
  4. Check the result. Verify the mitigations exist and work, and revisit the model when the design changes.

Not every STRIDE category applies to every element. An external entity (a user's browser) can be spoofed or can deny what it did, but you cannot tamper with "the user" as a diagram element; a data flow can be tampered with, read or interrupted, but it does not itself elevate privilege. A common rule of thumb maps categories to element types, and it is the basis for the stand-in below.

Stand-in 1: generate threat questions per element

The stand-in takes a tiny system model and, using the usual STRIDE-per-element mapping, prints the questions a review team should answer for each element. It does not find vulnerabilities by itself (a script cannot know your system), but it turns a diagram into a checklist, which is how real threat-modeling tools start.

JS STRIDE questions per element

Press Run (or Ctrl + Enter) to see the console output here.

No output.

A four-element model already produces 15 questions, which shows why teams model the important flows first (login, payment, data export) rather than everything at once. Add { name: "Admin console", type: "process" } to the model and run again: a single process adds six more questions, so the total grows to 21. Each question needs an answer such as "yes, mitigated by X" or "yes, accepted because Y"; an unanswered question is a risk nobody has looked at.

Open source and software licenses

Code you did not write is covered by a license: the legal terms that say what you may do with it. With no license, the default in most countries is that you may not copy, modify or distribute it. Open source licenses grant those rights under conditions. They fall into rough families:

  • Permissive (MIT, BSD, Apache-2.0): you may use the code in almost any project, including closed-source products, as long as you keep the copyright and license notice. Apache-2.0 also includes an explicit patent grant.
  • Weak or file-level copyleft (MPL-2.0, and LGPL for libraries): changes to the licensed files, or to the library itself, must be shared under the same terms, but your own separate code can have a different license. The exact conditions for LGPL depend on how the library is linked.
  • Strong copyleft (GPL): if you distribute a combined work that includes GPL code, the whole work must be offered under the GPL, with source. GPL-2.0-only and GPL-3.0 are not compatible with each other, so code under one cannot simply be mixed with code under the other.
  • Network copyleft (AGPL): like the GPL, and the obligation can also apply when users interact with the software over a network, even without distributing copies.
  • Proprietary / commercial: terms set by the owner, often forbidding copying and modification; read the agreement.

"Copyleft" is the idea that freedom must be passed on: whoever receives the code receives the same freedoms. The conditions are triggered by distribution (or, for AGPL, by network use), not by private use inside your own organization. Open source is also not the same as free of obligations: even the MIT license requires keeping the notice, and ignoring that is a license violation.

Practical habits for teams:

  • Keep an inventory of every dependency and its license, including transitive ones; tools can generate this list (a "software bill of materials").
  • Decide a policy up front: which licenses are pre-approved, which need review, which are forbidden for your product.
  • Check before you add, not at release time, when removing a dependency is expensive.
  • Contributing back also has a legal side: many projects ask contributors to sign an agreement or declare that they have the right to submit the code.
  • Generated and copied code (from examples or AI assistants) can carry license obligations too; treat it like any other incoming code.

Stand-in 2: a simplified license compatibility checker

The stand-in encodes a small version of the rules above: permissive dependencies are always fine, file-level copyleft is fine with a reminder, LGPL needs review, and GPL and AGPL dependencies force the project's own license. It reports OK, REVIEW or CONFLICT for each dependency. The table is deliberately incomplete and the dependency names are invented, so use it to learn the shape of the problem, not to clear a real release.

JS Check dependencies against a project license

Press Run (or Ctrl + Enter) to see the console output here.

No output.

With an Apache-2.0 project, the GPL-3.0 and GPL-2.0-only dependencies are conflicts: using them would force the whole distributed product to be released under the GPL. If the project itself is GPL-3.0, the first conflict disappears, because the project now satisfies the dependency's terms. The second one stays, since a GPL-2.0-only dependency demands GPL-2.0-only, which the checker lists as the only acceptable choice. That is the incompatibility between the two GPL versions in action. Options in a real conflict are: replace the dependency, ask the author for a different license, isolate it in a separate program (with legal advice), or change your own license.

Putting it together

Ethics, security and licensing are linked: a data breach is a security failure and a privacy harm; shipping code against its license is both a legal and an honesty problem; ignoring a vulnerability in a dependency you chose is a professional failure, not bad luck. The shared habit is to think about consequences before shipping and to leave a written trail of decisions: requirements for privacy and security, threat model results, license inventory and who approved each risk. When the answer is unclear, ask someone with the right expertise early, since the cost of a question is small and the cost of a surprise is not.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Your employer asks you to ship a feature that you believe puts users' safety at risk. According to professional codes of ethics, what should come first?

    Professional codes put the public interest first. Raise concerns in writing, propose alternatives and escalate if the risk is serious.
  2. 2. What does data minimization mean?

    Data you never collected cannot leak or be misused, so collect only what you need and keep it only as long as needed.
  3. 3. In STRIDE, what does the letter T stand for?

    STRIDE is Spoofing, Tampering, Repudiation, Information disclosure, Denial of service and Elevation of privilege.
  4. 4. Why is threat modeling most useful during design?

    Threat modeling works on a model of the system, so weaknesses can be fixed in the design before they are built in.
  5. 5. A project that will be sold as closed-source software wants to include a library licensed under the GPL-3.0. What is the most likely problem?

    Strong copyleft is triggered by distributing a combined work. Teams must replace the library, get another license or change their own plans. Ask a lawyer for real cases.

Summary

  • Professional codes of ethics put the public interest first and ask for honesty, fairness, respect for privacy and competence; ethical problems usually appear as ordinary schedule and scope pressure.
  • Privacy by design means data minimization, purpose limits, retention limits, access control, protection and transparency.
  • A secure SDLC adds security work to every phase; least privilege, defense in depth and failing securely are the recurring principles.
  • Threat modeling draws the system, asks what can go wrong with STRIDE, decides what to do about each threat and checks the result.
  • Licenses decide what you may do with code: permissive licenses keep a notice, copyleft licenses pass obligations on when you distribute, and every project needs a dependency inventory and policy. The stand-ins teach the shape of these problems; they are not legal advice.

Next: Project: Design a Library System.