LinuxQuestions.org
Help answer threads with 0 replies.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Security
User Name
Password
Linux - Security This forum is for all security related questions.
Questions, tips, system compromises, firewalls, etc. are all included here.

Notices


Reply
  Search this Thread
Old 10-01-2020, 04:13 PM   #1
_temp
LQ Newbie
 
Registered: Oct 2011
Posts: 17

Rep: Reputation: Disabled
Binaries on write protected media


Could placing binaries on write protected media be a thing?
Installing tripwire one of the install screens advised about storing binaries on write protected media.
How would one go about placing let's say one or a number of critical binaries on a write protected MC card (and have them reachable by the running system)? Remote tampering would be impossible this way.
Sorry if it is a trivial thing to do, and thanks for the ideas!
 
Old 10-01-2020, 04:36 PM   #2
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,445
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Binaries on write protected media

Yes, it's exactly what Android does. Very easy to do.

You can put whatever you want on any filesystem, not necessarily a removable one, and mount it read only.
 
Old 10-01-2020, 04:56 PM   #3
sgosnell
Senior Member
 
Registered: Jan 2008
Location: Baja Oklahoma
Distribution: Debian Stable and Unstable
Posts: 1,943

Rep: Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542Reputation: 542
Mounting read-only does not prevent altering the files if there is physical access, or even remote access. With the proper access, the filesystem could be remounted read/write, altered, then remoounted read-only again. If there is no physical access, the lock switch on an SD card would prevent remote access, but anyone who can get physical access can just move the switch. The only way I know of to do this is to use optical media - write to a CD or DVD and finalize it. But depending on the paranoia level, any of the above could work. With the proper security, just mounting read only could be sufficient. It's all a matter of having sufficient knowledge and motivation.
 
1 members found this post helpful.
Old 10-01-2020, 07:09 PM   #4
rkelsen
Senior Member
 
Registered: Sep 2004
Distribution: slackware
Posts: 4,445
Blog Entries: 7

Rep: Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553Reputation: 2553
Quote:
Originally Posted by sgosnell View Post
Mounting read-only does not prevent altering the files if there is physical access, or even remote access. With the proper access, the filesystem could be remounted read/write, altered, then remounted read-only again.
Proper access being the key words here. It's going to be as secure as you make it, but there are 3 simple steps you can follow to make it significantly more secure:

Set up a secure root password, don't share it with anyone, and, most importantly, don't run as root.
 
1 members found this post helpful.
Old 10-01-2020, 07:18 PM   #5
prushik
Member
 
Registered: Mar 2009
Location: Pennsylvania
Distribution: gentoo
Posts: 372

Rep: Reputation: 29
I would like to point out that even if you assure that your device is read-only in hardware, this still does not make your device tamper-proof, anyone with enough access to attempt to tamper with binaries on your device would likely be able to simply mount another file system over top of your read-only mount point. Even if you ensure that the device _only_ has read-only hardware, a tamperer could simply mount a tmpfs and put whatever they want there.
In other words, you can (using hardware) guarantee that your binaries are not tampered with, however, this does _not_ guarantee that the binaries you invoke will be the same ones on the device.

A strategy like this may work on some systems, but it requires a very restricted system, one where even the device admin does not have this kind of access.
 
Old 10-02-2020, 03:00 PM   #6
_temp
LQ Newbie
 
Registered: Oct 2011
Posts: 17

Original Poster
Rep: Reputation: Disabled
Thank you all for the thoughts!

I am aware of the different scenarios and threat levels (regarding physical access and so on). In my case accessing the machine from the network is the threat level. A good root password of course is necessary, but what I would like to achieve is to have binaries that need physical access to be modified. I'd start from here, and work my way up to different other methods of protection. Luckily I am not really any kind of interesting target, just a plain home user (and probably easy to guess that not with much sensitive data).

Is it called symlinking? What is the keyword I need to look for to learn about how to have my/some binaries in other places than the default install locations? Say, for example I would like to place the /bin/bash binary to /media/user/MCcard/binaries (I'm on Debian) and be invoked from there - how do I do I go about it?

Thanks again!
 
Old 10-02-2020, 03:28 PM   #7
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 647

Rep: Reputation: 189Reputation: 189
I guess using a squashfs-formatted root partition could provide a little more guarantees that the filesystem contained won't be modified (IIRC it's read only by design).
As others said, however, a motivated attacker with access to the system could be able to mount anything over it (i.e. this is what is normally done in OpenWRT systems, squashfs root partition + overlayfs writable data partitions), rendering the whole "system on a write protected media" security argument useless.
 
Old 10-02-2020, 04:27 PM   #8
prushik
Member
 
Registered: Mar 2009
Location: Pennsylvania
Distribution: gentoo
Posts: 372

Rep: Reputation: 29
Quote:
Originally Posted by _temp View Post
Is it called symlinking? What is the keyword I need to look for to learn about how to have my/some binaries in other places than the default install locations? Say, for example I would like to place the /bin/bash binary to /media/user/MCcard/binaries (I'm on Debian) and be invoked from there - how do I do I go about it?
A symbolic link (symlink) is basically the same as a shortcut file in windows if you are familiar to that. Its a file that just contains a reference to a file in another place. Yes, you would need to do this if you still plan on pursuing this, although IMO you gain very little security from such an endeavour. You will need to be aware, however, that (depending on which executables are located on your read only volume), this may complicate your boot process. If, for instance, you move all coreutils (or busybox) binaries to your read-only volume, then your symlinks will be broken when /media/user/MCcard/binaries is not mounted, and without the mount utility, you may not be able to mount the needed volume.

Historically, something like this scenario was a common problem, since many users kept /usr on a separate partition, and /usr/bin could contain binaries that were needed at boot time. This is generally not an issue any longer since nobody feels the need to do this anymore.

Now if you use an initramfs or initrd in your boot process, these could be used to mount your read-only volume, but how you do this depends on how your ramdisk is created (I don't know, I don't use a ramdisk in my boot process).
 
Old 10-03-2020, 03:46 AM   #9
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by _temp View Post
I am aware of the different scenarios and threat levels (regarding physical access and so on). In my case accessing the machine from the network is the threat level. A good root password of course is necessary, but what I would like to achieve is to have binaries that need physical access to be modified. I'd start from here, and work my way up to different other methods of protection. Luckily I am not really any kind of interesting target, just a plain home user (and probably easy to guess that not with much sensitive data).

Is it called symlinking? What is the keyword I need to look for to learn about how to have my/some binaries in other places than the default install locations? Say, for example I would like to place the /bin/bash binary to /media/user/MCcard/binaries (I'm on Debian) and be invoked from there - how do I do I go about it?
IMHO it comes down to sufficiently securing outside access to the system.

Additionally, look at how Android is doing these things. It probably won't get safer than that, at least technically (Android is unsafe for other reasons).
 
Old 10-03-2020, 04:25 PM   #10
BenCollver
Rogue Class
 
Registered: Sep 2006
Location: OR, USA
Distribution: Slackware64-15.0
Posts: 374
Blog Entries: 2

Rep: Reputation: 172Reputation: 172
That's what Puppy Linux does with its live CD.
 
Old 10-04-2020, 01:41 AM   #11
ondoho
LQ Addict
 
Registered: Dec 2013
Posts: 19,872
Blog Entries: 12

Rep: Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053Reputation: 6053
Quote:
Originally Posted by BenCollver View Post
That's what Puppy Linux does with its live CD.
That's what every Linux distro does with its Live CD.
 
Old 10-04-2020, 03:05 AM   #12
X-LFS-2010
Member
 
Registered: Apr 2016
Posts: 510

Rep: Reputation: 58
your drivers are made in china

too bad if one tick on one clock cycle in one chips is "tweaked right" that your chip has a back door in it that triggers normally quiet circuit to "do a job"

think of security that way
 
Old 10-04-2020, 03:17 AM   #13
X-LFS-2010
Member
 
Registered: Apr 2016
Posts: 510

Rep: Reputation: 58
Linux From Scratch (or XLFS's bash scripts) can show you how to create a linux OS on a disk, if that
s what your asking

but there are simple utilities to make linux OSes on a USB so you can't be asking that

what are you asking?

-----------------------------
symlinking ... hmmm, or ld (hard or soft links are both links)

do you mean "jails" from freebsd? sandboxes from (google, apple) ?

yea you can easily do "ln -s" on an OS tree into a tree you'll later make read-only (and your OS must support using the bits on the links not the destination files though - careful - does your kernel respect the top level directory bits or the bits on the symlink (on linux, i think, no, yes - but check))

you could then "chroot" (or pivotroot) to that tree ... and without LFS and some reading have some issues about not being able to log-in to your new OS disk because it it's disk cannot be written to (which is easy to fix, if you know how)

-----------------------------
TRIPWIRE IS OLD SCHOOL I CAN TELL YOU WHAT THEY MEANT TO ADVISE YOU UPON

* websites used to be available to the public on WORM CD media (read only media, so an attacker couldn't, say, take down Solaris.com or Yoohoo.gov) - they could cause a need of reboot at best but not "loose the website"

* HARD DRIVES (and some USB) have a write protect feature (a jumper). you would put all files on your server that shouldn't be altered and bump the jumper

* yes, root protection and read only bits "are supposed to work", but experience is that will get hacked if it is "a site on the internet open to the public".

-----------------------------
DO NOT put anything you much value on a PC unless you have scissors for the network cable and have damaged the wifi antenna. It Is Not Secure.

For example: did you know your cable modem (gov dessign "DOCIS") allows your cable company to watch what your doing on the web live as you are doing it? if you didn't ... well now you know.
 
Old 10-04-2020, 03:33 AM   #14
X-LFS-2010
Member
 
Registered: Apr 2016
Posts: 510

Rep: Reputation: 58
WARNING by someone who's had to use a rescue disk

IF you change your /lib or /bin or /sys "read only" it may bite you.

You don't know if "ubuntu" writes there during boot time (if it does, you may get frozen out of booting) (hey - rules aren't for big maintainers)

ALSO - if you upgrade and your bins are read-only, you'll end up having 1/2 an update (surely that could freeze you out of your PC)

-----------------------
WARNIGN: also - MOST LINUX DISTROS have a "trap" which prevents /lib from being accessed from anywhere except /lib (and there's a way to remove that but it requires some work be done, xlfs does this). so: if you tried to tell "ld" your /lib is in /foo/readonly/lib, and then moved your libs there? bash would mv the files and you'd be locked out and getting "nasty messages". it also inhibits testing new software and new systems or competing linux unless you go the whole 9 yards to make a whole OS disk (enough about that for now), AND prevents having "fall back libs" (incase the experiment fails, unless your in a chroot OS and fall out of that back to /lib)

-----------------------
POINT: do a backup before you go messing with your system files and be prepared to use it (ie, have a boot disk that works, know how to get your backup onto the disk, etc)

Last edited by X-LFS-2010; 10-04-2020 at 03:34 AM.
 
Old 10-04-2020, 04:23 AM   #15
X-LFS-2010
Member
 
Registered: Apr 2016
Posts: 510

Rep: Reputation: 58
ANOTHER TIP: modern systems have "extended security" (beyond user and read/write bits on files)

for example, on an apple computer no one can write to /bin except the apple installer during upgrade, not even 'root'. you have to reboot the computer to be able to "run as root", but even as root you can't clobber system files.

with modern linux KERNEL: root is not the "real root" either (root cannot write to anywhere in memory), you can write to system files (but if you compiled a custom linux kernel, you could lock that out)

so ... you may be ok without "physically locking your disk". all depends you know? that advice ... that's pretty old advice. surely it's good if you think "yea, if i get hacked i can still reboot, but i lost all my user files"

but on a modern IBM or amazon cloud, it runs many OS side-by-side (server hosting) "where each customer/server can't attack each other locally" ...

So i would say in the end ... cloud hosting: good. Write protect your disk: old technology but maybe useful if you leverage it well (ie, can boot after disaster, loose no content, be online as quick as loading a backup, etc)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Chrome binaries always work on older systems but Firefox binaries do not - what is the magic? Jason_25 Linux - Software 1 10-28-2019 11:23 AM
[SOLVED] usb drive: cannot remount block device /dev/sdb1 read-write, is write-protected schneidz Linux - Hardware 5 01-06-2015 03:15 PM
[SOLVED] Why does /media/cdrecorder pop up with "cd /media/ + tab" when I have /media/usb too? SharpyWarpy Fedora 6 11-22-2012 01:05 AM
[SOLVED] Displaying the contents of buffers in a protected and non-protected critical section mashhype Programming 5 11-22-2010 09:41 PM
Media, media, and oh yeah......media. Morbid SUSE / openSUSE 2 03-11-2007 08:50 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Security

All times are GMT -5. The time now is 01:01 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration