IBM MaaS360

IBM MaaS360

Join this online user group to communicate across Security product users and IBM experts by sharing advice and best practices with peers and staying up to date regarding product enhancements.

 View Only

Preventing browser access to TikTok on macOS Devices

By Chuck Brown posted Fri March 24, 2023 11:29 AM

  

We have discussed in different blog entries in the Security Community regarding what MaaS360 can do to remove TikTok from devices and prevent its usage, but that centered on the TikTok application.

But how can we prevent a person from accessing www.tiktok.com on a macOS device using any browser?

Individual browser blocklist configuration values on macOS and Windows can prevent access but that’s a lot of work.  You can’t even depend on those configuration variables because someone may have a different browser that we may not have known about.

We need to look at blocking at a macro level.

A straightforward way to make this happens is to update the host file on your macOS machine.

Process

Here are the steps:

1.       Open the text editor of your choice.

2.       Create a SH file containing some of the example code

a.       Choose from the examples

3.       Open File Explorer

4.       Replace the host file

The TikTok URL will no long be accessible from a Windows based Browser

Example 1

#!/bin/bash     

echo '127.0.0.1 localhost  www.tiktok.com' >> /etc/hosts

echo '127.0.0.1 localhost  tiktok.com' >> /etc/hosts

Example 2

echo "127.0.0.1 localhost `hostname`">./temp_hosts

echo "127.0.0.1 tiktok.com">>./temp_hosts

echo "127.0.0.1 www.tiktok.com">>./temp_hosts

cat /etc/hosts |tail -n +2 >>./temp_hosts

cat ./temp_hosts > /etc/hosts

rm ./temp_file

Distribution of Shell Script with MaaS360

 

Create a group for Mac Devices

Execute you host shell script.

Upload and distribute

1 comment
14 views

Permalink

Comments

Thu August 14, 2025 06:13 AM

We’ve done the hosts file block on a few Macs here and it works fine for TikTok, since it cuts it off for every browser. Biggest thing I’ve run into is users just editing the file back, so if they have admin rights it’s kind of a game of whack-a-mole.

If you’re using MaaS360 anyway, you can just push the script on a schedule so it reverts any changes. Another option is to pair it with a firewall rule or DNS block so you’re covering both ends — that way it still works if someone takes the laptop off-site.

Only downside is if you’ve got a really long hosts file, macOS networking can get a bit sluggish. Haven’t had a problem yet for just one or two domains though.