Skip to content
Parallax Learn

Parallax Learn

  • Welcome
  • Tutorials
        • Tutorial Series head tag

          Tutorial Series
        • Tutorial Series

          The special, classroom-ready series pages are organized collections of tutorials for our most popular hardware and/or languages. The tutorials for each topic are conveniently accessible from a single page, shown in the order it is recommended that they be completed.
        • Robotics Series Head tag

          Robotics Series
        • Robotics Series

          • Artificial Intelligence
          • Cybersecurity: Radio Data tutorialCybersecurity
          • cyber:bot + Python
          • cyber:bot + MakeCode
          • Boe-Bot Tutorial SeriesBoe-Bot
          • Arduino Shield-Bot
          • ActivityBot with C TutorialsActivityBot + C
          • ActivityBot with BlocklyProp Tutorial SeriesActivityBot + BlocklyProp
          • Scribbler 3 Tutorial SeriesScribbler 3
        • Electronics & Programming Series Head tag

          Electronics & Programming Series
          • BS2 Board of Education Tutorial SeriesBS2 Board of Education
          • Propeller C-Language BasicsPropeller C Basics
          • FLiP Try-It Kit C Tutorial SeriesFLiP Try-It Kit + C
          • FLiP Try-It Kit BlocklyProp TutorialsFLiP Try-It Kit + BlocklyProp
          • Badge WX Tutorial SeriesBadge WX
          • Propeller BlocklyProp Basics and ProjectsPropeller BlocklyProp Basics
          • View All Tutorial Series »
        • Browse Tutorials
        • Browse Tutorials

          Individual tutorials sorted by robot or kit, and language.
        • By Robot or Kit
          • ActivityBot
          • SumoBot WX
          • Boe-Bot
          • Shield-Bot
          • cyber:bot
          • Badge WX
          • ELEV-8
          • ARLO
        • By Language
        • By Language

          • Propeller C
          • Arduino
          • BlocklyProp
          • PBASIC
          • Python
          • MakeCode
          • View All Tutorials »
  • Educators
  • Reference
  • Downloads
  • Home
  • All Courses
  • Cybersecurity: Malformed Packet Attacks & Defenses

Cybersecurity: Malformed Packet Attacks & Defenses

Your Turn: Add a Vulnerability

Did You Know: It’s Complicated!

Applications don’t normally have just one vulnerability, so it’s best to test for more than one scenario.  For example, what if the dictionary packet is changed to some other object, like maybe a string?  This is just one example of the kinds of questions that application security validation specialists help with as part of software development.

Your Turn: Add Another Vulnerability

Your receive script is hardened against one kind of malformed packet attack, but what if there are more?  In the first example, the dictionary contained an unexpected term.  What if the dictionary is instead not a dictionary?  That would cause another kind of exception that the receiver script is not yet hardened against.  

  • Modify the sender script as shown.
  • Set its project name to countdown_sender_w_malformed_packet_options_your_turn.
  • Flash it into the sender micro:bit by clicking Send to micro:bit.
  • Repeat the tests, but also try entering the value -2 in response to the Enter seconds to count down:  prompt.
  • Verify that this also causes an exception and make a note of the line number where the exception occurs.
  • In the Receiver Script, move the Try: statement above where the exception occurred and indent all the lines between where the Try: statement was and where it is now.
  • Set the project name of the modified Receiver script to countdown_receiver_w_more_exception_handling_your_turn.
  • In both micro:bit Python Editors, click Save. 
  • Flash it into the receiver micro:bit by clicking Send to micro:bit.
  • Repeat the tests again and verify that the second malformed packet attack using a countdown of -2  has been mitigated.

Sender Script

Receiver Script

 

 


Printer-friendly version
Try This: Add Exception Handling
Prev
Malformed Packets and Sharing Something
Next

DISCUSSION FORUMS | PARALLAX INC. STORE

About | Terms of Use | Feedback: learn@parallax.com | Copyright©Parallax Inc. 2024

© 2025 Parallax Learn • Built with GeneratePress