Ask Dr. Mohammad locally, or prepare an experiment-aware prompt for ChatGPT, Gemini or Claude. The external providers open in their own tabs; nothing is automatically submitted.
Public course objective, displayed commands, source excerpts and procedure. Private assessment content is not collected.
Prepare a contextual AI prompt
0 characters
Common secret and email patterns are redacted on preparation; this is not a comprehensive privacy filter. Review the entire editable prompt, including student work and unpublished research, before sharing. The providers apply their own accounts, privacy settings and limits.
Separate broker authentication from topic authorization using positive and negative controls.
The focus of this experiment is to trace MQTT credentials and topic ACL decisions. Students then compare authorized and unauthorized operations under least privilege, and verify expected broker acceptance and denial on local fixtures. The Concepts view explains the operation before the practical work; the Simulation view is used to examine reference and changed inputs, not to substitute for actual measurements.
Learning objectives
Trace MQTT credentials and topic ACL decisions.
Compare authorized and unauthorized operations under least privilege.
Verify expected broker acceptance and denial on local fixtures.
Identify the configured inputs (Listener; Principal; Credential; MQTT operation; Topic) and record the corresponding observed outputs with units where applicable.
Compare the reference calculation or decision with an independent implementation or authorized observation; state any discrepancy and the applicable model boundary.
Expected learning outcomes
On completion, students can trace MQTT credentials and topic ACL decisions, compare authorized and unauthorized operations under least privilege, and verify expected broker acceptance and denial on local fixtures.
Required deliverables
Submit the derivation or state trace for the named operation, the exact reference and changed configurations, the associated simulator or practical evidence, and a short validation statement addressing verify expected broker acceptance and denial on local fixtures. Separate predicted values from observations.
Prerequisite knowledge and related learning
Review the following catalogue prerequisites before starting. After completion, continue to K04 · TLS certificate trust & endpoint identity.
The specified isolated laboratory environment, with local synthetic inputs and authorized services only. Use the experiment-specific setup and verification instructions.
Begin with a manual prediction, record the baseline, change one independent condition at a time, and compare the resulting trace or measurements with the original prediction. Record observations and uncertainty separately from reference values. Follow the experiment’s specific procedure, safety limits, and acceptance checks.
CONCEPTS / ACTIVE RECALL
Understand the experiment
Scientific architecture · MQTT v5 identity and topic ACL
Authentication establishes principal identity; authorization checks action and topic. Successful connection does not grant unrestricted publish rights.
Before operating the equipment or executing the program, derive the expected outcome using the required theoretical work in Experiment. Use the diagram to identify the variables and system boundaries.
Scientific theory · Identity versus permissions
Authentication verifies a claimed principal using configured credentials. Authorization evaluates what that principal may do after connection. An MQTT ACL can restrict publish and subscribe actions independently by topic. Least privilege grants only the operations required for the device role.
Worked example and engineering interpretation
A sensor allowed to publish its own temperature topic need not be allowed to subscribe to all devices or publish a command. Test one intended operation and one prohibited operation with a classroom account; distinguish connection rejection from authorization rejection.
Engineering principles · additional worked teaching example
Authentication establishes identity; authorization restricts operations. A valid identity may be denied publishing to an operator-only topic. A controlled experiment varies principal or requested action, not both, and records reason for denial.
From theory to experiment
Predict the reference result before operating the workbench; check the actual intermediate state, units and constraints. The existing simulation, implementation and procedure below are distinct sources of evidence.
How to investigate K03 · MQTT authentication & least privilege
Distinguish authentication and authorization using positive and negative MQTT 5 controls.
Analytical investigation means collecting an observation, identifying the mechanism, using a calculation or state trace to explain it, and checking your conclusion against evidence. Controlled comparison means changing one independent variable, holding the remaining relevant conditions constant, and measuring a dependent variable against a baseline. Experimental validation means comparing a predicted result to a reproducible observation or assertion; agreement inside a model does not certify hardware. Evidence-based reasoning connects a specific observation to a theoretical rule and states uncertainty, not merely an opinion. Performance characterization records a named metric and its units across conditions; sensitivity analysis changes one parameter across several values. A threat assessment links an asset, threat, consequence and evidence to a mitigation.
Experiment-specific guided practice
Objective: Distinguish authentication and authorization using positive and negative MQTT 5 controls.
Use protected listener, sensor, correct credential and telemetry PUBLISH. Inspect CONNECT, CONNACK and PUBACK.
Change identity to viewer without changing operation; record the denial after successful authentication.
Switch viewer to SUBSCRIBE on telemetry and compare SUBACK.
Change credential to incorrect and verify that no topic operation is evaluated.
Reference check:
Model boundary:
Independent task and submission evidence
2. Change identity to viewer without changing operation; record the denial after successful authentication. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
Before execution write the independent variable and its levels, dependent observation with units where applicable, baseline, controlled variables, measurement method and expected result. For a state machine use state/event/output rather than inventing a numeric metric. Record failures and repeat the baseline. A weak conclusion is “it works”; a supported conclusion names the changed setting, observed value/state, corresponding rule and one limitation.
Trial
Changed setting
Fixed settings
Predicted result
Actual observation / units
Evidence / uncertainty
A: baseline
Reference
Record
Predict
Record
Record
B: one change
Record
Same as A
Predict
Record
Record
A: repeat
Restore
Same as A
Predict
Record
Record
Completion: submit the filled table, relevant simulator screenshot or terminal/notebook output, reasoning with units/assumptions, and one limitation. Preserve the independent assessment questions; this guide does not fill their answers.
Worked engineering reasoning and boundary conditions
Engineering reference configuration: Listener = protected; Principal = sensor; Credential = correct; MQTT operation = PUBLISH; Topic = psut-kali/demo/telemetry. In the classroom model, Connected = Yes; Operation accepted = Yes; Application acknowledgment = PUBACK. Protected listener applies the declared teaching ACL. Simplified exact-topic ACL and MQTT v5 reason model; no real broker connection.
Use the diagram to follow the calculation or state progression. Keep the teaching configuration separate from the independent exercise values; compare observations with the actual model and implementation.
Concept animation · message sequence
Explore the teaching example independently of the simulator. Each step reveals an operation, data relationship or calculated state. The Simulation view has separate editable inputs.
Step 1 of 5 · CONNECT sensor
CONNECT sensor
1. Client → Broker
CONNECT sensor
CONNACK success
1. Client → Broker
CONNECT sensor
2. Broker → Client
CONNACK success
PUBLISH
1. Client → Broker
CONNECT sensor
2. Broker → Client
CONNACK success
3. Client → Broker
PUBLISH
Check ACL
1. Client → Broker
CONNECT sensor
2. Broker → Client
CONNACK success
3. Client → Broker
PUBLISH
4. Broker → Topic policy
Check ACL
PUBACK success
1. Client → Broker
CONNECT sensor
2. Broker → Client
CONNACK success
3. Client → Broker
PUBLISH
4. Broker → Topic policy
Check ACL
5. Broker → Client
PUBACK success
Teaching example only; inspect live calculations or real practical evidence separately.
Recall the concept before revealing its explanation.
0 / 3 revealed
K03 · 01 / 08Authentication versus authorization?Reveal explanation
Engineering explanation
Authentication verifies identity; authorization checks whether the identity may perform an operation.
K03 · 02 / 08Why test positive controls?Reveal explanation
Engineering explanation
A timeout alone cannot establish that an ACL rejected a publication.
K03 · 03 / 08Which accepted and rejected access cases must be established?Reveal explanation
Engineering explanation
Keep both K02 brokers running. Execute from ~/kali-labs in terminal C. Require matching MQTT 5 reason codes and successful authorized delivery before and after rejection; any timeout is inconclusive.
K03 · 04 / 08How does authorization differ from authentication?Reveal explanation
Engineering reasoning
Authentication establishes identity; authorization decides which topic/action that identity is permitted to perform.
K03 · 05 / 08Why include a denied operation in an ACL experiment?Reveal explanation
Engineering reasoning
A positive publish alone cannot establish least privilege; a forbidden operation must also be rejected.
K03 · 06 / 08A broker accepts one client but rejects a topic write. Select every technically valid statement.
A. Authentication and authorization are separate controls.
B. Test both allowed and denied actions.
C. Authentication implies permission to publish on all topics.
D. A denied write proves the client's identity was never established.Reveal explanation
Applied scenario
Correct: A. Authentication and authorization are separate controls.; B. Test both allowed and denied actions.
K03 · 07 / 08In K03 · MQTT authentication & least privilege, which command or code executes the final documented practical action?Reveal explanation
K03 · 08 / 08For K03 · MQTT authentication & least privilege, which actual output or state confirms the prescribed practical run succeeded, and what does it not establish?Reveal explanation
Evidence & acceptance
K02 both broker terminals must remain running. In a third Kali terminal verify dependencies, run python3 lab.py mqtt. Require all checks pass, including authorized delivery before and after rejected operations, MQTT 5 reason codes and no unauthorized delivery. Timeout or TLS failure is not proof of authorization. Keep credentials private.
Loading experiment-specific apparatus…Previous model / additional reference tools
Simulation task
Distinguish authentication and authorization using positive and negative MQTT 5 controls.
Explore the model using its own controls. Record a prediction before changing a condition. Compare the reference with a changed condition, then use the Experiment tab for the procedure, acceptance criteria and notebook. Model outputs and physical observations must remain separate.
Predict the outcome, change either condition, then compare the modeled decision. This illustrates the selected control criteria, not a full implementation or measurement.
01 · InputMQTT authorization
→
02 · Evaluate2 of 2 checks
→
03 · OutcomeConditions met
CONTROL PATH · VIRTUAL INSTRUMENTCONDITIONS MET
Signal path illustrates a decision rule. The indicator is not actual network traffic, cryptographic verification or device measurement.
Publish or subscribe allowed
Reference conditions selected.
Reference conditions selected.
Complete the actual local Kali procedure below. The workbench does not send packets, perform cryptography, inspect a device or establish that real controls are effective.
Closed two-condition teaching fixture; actual security validation requires the practical procedure.
Loading instrument…
Awaiting model display.
Experimental instrumentation · A/B
Compare two model conditions
Capture a baseline, change one experimental condition, run the model if required and capture the comparison. Snapshots contain visible controls and display text, not physical sensor readings. Review before exporting.
Keep both K02 brokers running. Execute from ~/kali-labs in terminal C. Require matching MQTT 5 reason codes and successful authorized delivery before and after rejection; any timeout is inconclusive.
Experimental protocol
Prerequisites
K02; both broker terminals remain open
Procedure
Run the MQTT v5 verifier. It waits for CONNACK/SUBACK and records PUBACK and exact delivery.
Acceptance
Six checks: plaintext and authorized TLS delivery, denied viewer PUBACK 135, rejected anonymous and wrong-password CONNACK, post-denial authorized delivery. Timeout is inconclusive/fail.
Evidence
K03-MQTT.json and redacted decision lines in broker logs.
Standards link
Logical access to interfaces; ETSI credentials; MQTT v5 reason codes
Discussion
Explain why a missing marker alone cannot prove authorization denial.
Run & verify — acceptance checklist
Build verification: MQTT acknowledgment evaluation logic tested with fixtures; live broker pending.
K02 both broker terminals must remain running. In a third Kali terminal verify dependencies, run python3 lab.py mqtt. Require all checks pass, including authorized delivery before and after rejected operations, MQTT 5 reason codes and no unauthorized delivery. Timeout or TLS failure is not proof of authorization. Keep credentials private.
Record the actual output, source (mock/model or physical), and any error. A missing tool, timeout or untested external service is not a pass.
Before the simulation or practical, solve both experiment-specific tasks. List the given inputs, show the intermediate calculation or state trace, identify the expected observation, and state a limitation. Show formulas and intermediate calculations where relevant, or draw the requested state/sequence diagram. These are independent classroom fixtures; where they differ from the reference configuration below, do not treat them as measured values. Compare your predictions with the corresponding experiment afterwards.
01 · Predict and derive using the given inputs
Construct a table for sensor, observer and operator with allowed publish/subscribe operations from the lab policy.
Engineering method — Authentication establishes identity; authorization restricts operations. A valid identity may be denied publishing to an operator-only topic. A controlled experiment varies principal or requested action, not both, and records reason for denial. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
02 · Compare or justify using evidence
For correct credentials and a forbidden topic, predict separate connection and operation decisions. Repeat with invalid credentials and explain why the second check is not reached.
Engineering method — Authentication establishes identity; authorization restricts operations. A valid identity may be denied publishing to an operator-only topic. A controlled experiment varies principal or requested action, not both, and records reason for denial. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
03 · Policy analysis
Policy analysis · Independent work
A fictional sensor may publish telemetry and an observer may subscribe to telemetry. Both authenticate correctly. Evaluate observer publishing and sensor subscribing when no other permissions are granted.
Policy analysis — Authentication establishes identity; authorization restricts operations. A valid identity may be denied publishing to an operator-only topic. A controlled experiment varies principal or requested action, not both, and records reason for denial. Apply this method to the assigned values independently; compare your reasoning with the relevant simulator or practical implementation.
Work is saved locally when browser storage is available. Export it for submission; no remote upload or automatic grade is assigned.
Expanded independent theoretical exercise bank
Progress from calculation and interpretation to diagnosis and controlled engineering design. Complete the questions without opening the simulation first; show intermediate steps.
Intermediate · Explain a changed-input result
Independent theoretical exercise · K03-01
Use the reference configuration (Listener = protected; Principal = sensor; Credential = correct; MQTT operation = PUBLISH; Topic = psut-kali/demo/telemetry), but change Principal = anonymous. The model reports Connected = No. Explain the governing rule and assumptions that make this output plausible; identify an independent verification method.
Intermediate · Interpret a state transition
Independent theoretical exercise · K03-02
The reference model reports Connected: Yes. Under Principal = anonymous it reports No. Explain which configured condition changed and what the two outputs establish, and what they do not establish.
Intermediate · Interpret a technical trace
Independent theoretical exercise · K03-03
For MQTT operation = SUBSCRIBE, the model supplies this excerpt from MQTT control packet trace:
Packet · Context · Decision
CONNECT · sensor · 0x00 Success
SUBSCRIBE · psut-kali/demo/telemetry · 0x87 Not authorized
Count rows whose Context value is exactly “sensor”, and identify the displayed row numbers. Explain what the count describes.
Advanced · Reverse reasoning
Independent theoretical exercise · K03-04
An observation is Operation accepted = No. Candidate A uses Listener = protected; Principal = sensor; Credential = correct; MQTT operation = PUBLISH; Topic = psut-kali/demo/telemetry. Candidate B changes the listed settings (MQTT operation = SUBSCRIBE) and keeps the remaining settings fixed. Which is consistent with the observation? If both can explain it, say what additional evidence is required.
Advanced · Diagnose a reported mismatch
Independent theoretical exercise · K03-05
A student configures Topic = psut-kali/demo/commands while preserving all other reference settings, but copies the reference report of Operation accepted = Yes. Evaluate whether the report is justified. Identify the first configuration/output check to perform.
Challenging · Design a controlled verification
Independent theoretical exercise · K03-06
Design a controlled comparison for K03 · MQTT authentication & least privilege using reference Listener = protected; Principal = sensor; Credential = correct; MQTT operation = PUBLISH; Topic = psut-kali/demo/telemetry and test Principal = anonymous. Specify the changed setting(s), measured metric Connected, controls, repetitions, an acceptance check and what evidence can distinguish an actual implementation from the model.
Step-by-step experimental procedure
Separate broker authentication from topic authorization using positive and negative controls.
1 · Reference workbench configuration
Use the named reference workbench and its reference inputs. Additional live instruments may have different controls; use the matching instrument. Record virtual and practical results separately.
Listenerprotected
Principalsensor
Credentialcorrect
MQTT operationPUBLISH
Topicpsut-kali/demo/telemetry
2 · Perform the investigation in order
Use protected listener, sensor, correct credential and telemetry PUBLISH. Inspect CONNECT, CONNACK and PUBACK.
Change identity to viewer without changing operation; record the denial after successful authentication.
Switch viewer to SUBSCRIBE on telemetry and compare SUBACK.
Change credential to incorrect and verify that no topic operation is evaluated.
Select outside/topic with correct sensor credentials; explain why authentication is insufficient.
Run lab.py mqtt in your own Kali environment, reconcile individual result and broker reason codes; do not reveal credentials.
3 · Compare controlled trials
Trial
Independent change
Expected check
Observation
Sensor publishes
Use reference inputs above
Operation accepted: Yes
Record actual result
Viewer publishes
Principal = viewer
Operation accepted: No
Record actual result
Viewer subscribes
Principal = viewer; MQTT operation = SUBSCRIBE
Operation accepted: Yes
Record actual result
Wrong password
Credential = incorrect
Connected: No
Record actual result
Outside topic
Topic = outside/topic
Operation accepted: No
Record actual result
4 · Analyze and report
Which control prevents an authenticated viewer from publishing?
Required evidence: CONNECT/operation decisions and the actual local K03 evidence report.
Model boundary: Simplified exact-topic ACL and MQTT v5 reason model; no real broker connection.
Controlled investigation · reproducible evidence
Method. Use the existing reference workbench configuration and the named controlled changes below. A controlled variable stays fixed while the independent variable is intentionally changed; the dependent variable is the resulting observed output. First predict each trial from the Concepts page. Run the baseline, then change only the specified setting and record the outcome. For deterministic traces one execution per case and a repeated verification are sufficient; for timing or stochastic measurements repeat at least five times, recording each run, median and range. Reset to the reference state between independent comparisons.
Trial
Independent change
Dependent observation
Sensor publishes
Use reference inputs above
Record actual outcome and units
Viewer publishes
Principal = viewer
Record actual outcome and units
Viewer subscribes
Principal = viewer; MQTT operation = SUBSCRIBE
Record actual outcome and units
Wrong password
Credential = incorrect
Record actual outcome and units
Evidence: attach the completed comparison table, one trace or screenshot per condition, and actual practical terminal/hardware evidence where applicable. Explain any prediction mismatch and distinguish modeled behavior from measured results.
Loading laboratory-specific procedure…
Python / Google Colab notebook
Bounded notebook reference exercise; original device/service commands are reference-only. Validated locally in a fresh Jupyter kernel. Download, then upload to Google Colab.
✓ Expected: The saved JSON shows individual outcomes. Missing reports or failed controls require investigation, not a pass.
Kali terminal A / B: Inspect foreground broker logs; record only reason codes and decision lines.
Experimental notebook
Record your own results. Values are not prefilled or independently verified.
Method and implementation
Review the implementation after attempting the practical steps.
Test design · method and source
Inspect the explicit MQTT v5 CONNACK, SUBACK and PUBACK reason codes. No marker alone is insufficient. The Paho client waits for subscription acknowledgment and repeats the authorized control after the denied operation. Credentials remain in Python memory during this test.
Download this notebook and open Google Colab. Select File → Upload notebook and choose the downloaded .ipynb.
Read the Markdown instructions before each executable cell. Use a Python runtime, run cells from top to bottom, and resolve imports if necessary.
Perform the baseline and controlled changes. Save the notebook with actual outputs and your written interpretation.
Execution scope: Default computational cells passed isolated local Python execution; physical equipment and live services require separate verification.
01Instructions · Markdown
# K03 · K03 · MQTT authentication & least privilege
**PSUT IoT Engineering Studio — Dr. Mohammad Alja’afreh**
## Introduction
Distinguish authentication and authorization using positive and negative MQTT 5 controls.
## How to run
1. Download this notebook from the laboratory page. Open Google Colab → File → Upload notebook.
2. Select a Python CPU runtime. Run cells from top to bottom using Shift+Enter, or Runtime → Run all.
3. Read the printed observations and assertions. Change one parameter at a time and rerun the relevant cell.
4. Save your own outputs and compare them to the portal Experiment tab.
**Execution boundary:** Bounded notebook reference exercise; original device/service commands are reference-only. Do not run the hardware or service commands in Colab. No real credentials are needed. The notebook is self-contained.
02Instructions · Markdown
## Experiment-specific preparation
Distinguish authentication and authorization using positive and negative MQTT 5 controls.
**Reference procedure (use the matching simulator/WSL tool where named, not an unrelated service):**
1. Use protected listener, sensor, correct credential and telemetry PUBLISH. Inspect CONNECT, CONNACK and PUBACK.
2. Change identity to viewer without changing operation; record the denial after successful authentication.
3. Switch viewer to SUBSCRIBE on telemetry and compare SUBACK.
4. Change credential to incorrect and verify that no topic operation is evaluated.
5. Select outside/topic with correct sensor credentials; explain why authentication is insufficient.
**Evidence:**
**Boundary:**
03Instructions · Markdown
## 1. Objectives and reference condition
- Reproduce the specific computational mechanism in this laboratory.
- Inspect the output, compare the reference condition with a changed or rejected condition where implemented, and explain any discrepancy.
- Distinguish actual local Python execution from mock, physical and external-service observations.
## 2. Environment check
04Python · executable cell
PYTHON · Code cell
# =====================================================================
# K03 | Code cell 01 | K03 · MQTT authentication & least privilege
# Purpose: 1. Objectives and reference condition - Reproduce the specific computational mechanism in this laboratory. - Inspect the output, compare the reference condition with a changed or rejected condition where implem
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
import sys
print("Python",sys.version.split()[0])
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert sys.version_info >= (3,10)
## 3. Implementation
Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
06Python · executable cell
PYTHON · Code cell
# =====================================================================
# K03 | Code cell 02 | K03 · MQTT authentication & least privilege
# Purpose: 3. Implementation Read the comments and variable definitions before execution. Assertions must pass; inspect values, not just completion.
# Inputs: the explicit fixture/settings below and any preceding cell state.
# Output: inspect printed values, returned records or assertions; record evidence.
# =====================================================================
# Closed policy fixture, not Mosquitto authentication.
acl={'publisher':{'publish'},'observer':{'subscribe'}}
# Repeat the same operation for each configured input so observations are comparable.
for role,action in [('publisher','publish'),('observer','publish'),('observer','subscribe')]:print(role,action,action in acl[role])
# Check the expected invariant so a mismatch fails visibly instead of appearing successful.
assert 'publish' not in acl['observer']
## Original portal implementation (reference only)
These are the actual laboratory snippets. They are retained for comparison; follow the portal setup for WSL, hardware or services. They are **not** executed by Run all.
```bash
python3 lab.py mqtt
```
08Instructions · Markdown
## 4. Results and analysis
Record the actual output and whether the assertions pass. Identify a parameter to vary, state your prediction, repeat the reference calculation, then explain the changed result.
| Trial | Configuration | Observation | Interpretation |
|---|---|---|---|
| A | Reference | | |
| B | One controlled change | | |
| C | Reference repeat | | |
**Limitations:** Bounded notebook reference exercise; original device/service commands are reference-only. Notebook success does not certify external equipment or services.
09Instructions · Markdown
## Guided reasoning and evidence
A controlled comparison changes one independent input while keeping the other relevant inputs fixed; the dependent variable is the recorded output. Use this lab’s reference condition above.
**Independent task:** 2. Change identity to viewer without changing operation; record the denial after successful authentication. Record the named input, prediction, actual output and one limitation; restore the original condition and repeat.
| Trial | Input/configuration | Prediction | Observation | Evidence / limitation |
|---|---|---|---|---|
| A | Reference | | | |
| B | Changed input | | | |
| A repeat | Reference | | | |
A conclusion is supported only when it cites the recorded values or observed states and explains them with the experiment theory.
Shared research workbenches · network designer & advanced studiesConcurrent-device simulation & Monte Carlo research