A filtering algorithm implemented by a filtering module in an implantable medical device (IMD), or in an external device for communicating with an IMD, is disclosed which reviews blocks based on a number of rules. The filtering module preferably comprises both firewall and instruction analysis modules. The instruction analysis module analyzes the instructions and associated data (if present) in each block to determine whether such blocks would compromise operation of the IPG or injure a patient if executed. Instruction rules corresponding to an instruction identified in the block are retrieved by the instruction analysis module. The instruction analysis module reviews the block per the retrieved rules, and possibly also in light of current and historical IPG therapy setting or mode data, or other received but un-executed blocks. If a block is compliant, it is executed by the IMD or transmitted to the IMD.