1*517393d9SAndrew Geissler.. SPDX-License-Identifier: CC-BY-SA-2.0-UK 2*517393d9SAndrew Geissler 3*517393d9SAndrew GeisslerMaking Images More Secure 4*517393d9SAndrew Geissler************************* 5*517393d9SAndrew Geissler 6*517393d9SAndrew GeisslerSecurity is of increasing concern for embedded devices. Consider the 7*517393d9SAndrew Geisslerissues and problems discussed in just this sampling of work found across 8*517393d9SAndrew Geisslerthe Internet: 9*517393d9SAndrew Geissler 10*517393d9SAndrew Geissler- *"*\ `Security Risks of Embedded 11*517393d9SAndrew Geissler Systems <https://www.schneier.com/blog/archives/2014/01/security_risks_9.html>`__\ *"* 12*517393d9SAndrew Geissler by Bruce Schneier 13*517393d9SAndrew Geissler 14*517393d9SAndrew Geissler- *"*\ `Internet Census 15*517393d9SAndrew Geissler 2012 <http://census2012.sourceforge.net/paper.html>`__\ *"* by Carna 16*517393d9SAndrew Geissler Botnet 17*517393d9SAndrew Geissler 18*517393d9SAndrew Geissler- *"*\ `Security Issues for Embedded 19*517393d9SAndrew Geissler Devices <https://elinux.org/images/6/6f/Security-issues.pdf>`__\ *"* 20*517393d9SAndrew Geissler by Jake Edge 21*517393d9SAndrew Geissler 22*517393d9SAndrew GeisslerWhen securing your image is of concern, there are steps, tools, and 23*517393d9SAndrew Geisslervariables that you can consider to help you reach the security goals you 24*517393d9SAndrew Geisslerneed for your particular device. Not all situations are identical when 25*517393d9SAndrew Geisslerit comes to making an image secure. Consequently, this section provides 26*517393d9SAndrew Geisslersome guidance and suggestions for consideration when you want to make 27*517393d9SAndrew Geissleryour image more secure. 28*517393d9SAndrew Geissler 29*517393d9SAndrew Geissler.. note:: 30*517393d9SAndrew Geissler 31*517393d9SAndrew Geissler Because the security requirements and risks are different for every 32*517393d9SAndrew Geissler type of device, this section cannot provide a complete reference on 33*517393d9SAndrew Geissler securing your custom OS. It is strongly recommended that you also 34*517393d9SAndrew Geissler consult other sources of information on embedded Linux system 35*517393d9SAndrew Geissler hardening and on security. 36*517393d9SAndrew Geissler 37*517393d9SAndrew GeisslerGeneral Considerations 38*517393d9SAndrew Geissler====================== 39*517393d9SAndrew Geissler 40*517393d9SAndrew GeisslerThere are general considerations that help you create more secure images. 41*517393d9SAndrew GeisslerYou should consider the following suggestions to make your device 42*517393d9SAndrew Geisslermore secure: 43*517393d9SAndrew Geissler 44*517393d9SAndrew Geissler- Scan additional code you are adding to the system (e.g. application 45*517393d9SAndrew Geissler code) by using static analysis tools. Look for buffer overflows and 46*517393d9SAndrew Geissler other potential security problems. 47*517393d9SAndrew Geissler 48*517393d9SAndrew Geissler- Pay particular attention to the security for any web-based 49*517393d9SAndrew Geissler administration interface. 50*517393d9SAndrew Geissler 51*517393d9SAndrew Geissler Web interfaces typically need to perform administrative functions and 52*517393d9SAndrew Geissler tend to need to run with elevated privileges. Thus, the consequences 53*517393d9SAndrew Geissler resulting from the interface's security becoming compromised can be 54*517393d9SAndrew Geissler serious. Look for common web vulnerabilities such as 55*517393d9SAndrew Geissler cross-site-scripting (XSS), unvalidated inputs, and so forth. 56*517393d9SAndrew Geissler 57*517393d9SAndrew Geissler As with system passwords, the default credentials for accessing a 58*517393d9SAndrew Geissler web-based interface should not be the same across all devices. This 59*517393d9SAndrew Geissler is particularly true if the interface is enabled by default as it can 60*517393d9SAndrew Geissler be assumed that many end-users will not change the credentials. 61*517393d9SAndrew Geissler 62*517393d9SAndrew Geissler- Ensure you can update the software on the device to mitigate 63*517393d9SAndrew Geissler vulnerabilities discovered in the future. This consideration 64*517393d9SAndrew Geissler especially applies when your device is network-enabled. 65*517393d9SAndrew Geissler 66*517393d9SAndrew Geissler- Regularly scan and apply fixes for CVE security issues affecting 67*517393d9SAndrew Geissler all software components in the product, see ":ref:`dev-manual/vulnerabilities:checking for vulnerabilities`". 68*517393d9SAndrew Geissler 69*517393d9SAndrew Geissler- Regularly update your version of Poky and OE-Core from their upstream 70*517393d9SAndrew Geissler developers, e.g. to apply updates and security fixes from stable 71*517393d9SAndrew Geissler and LTS branches. 72*517393d9SAndrew Geissler 73*517393d9SAndrew Geissler- Ensure you remove or disable debugging functionality before producing 74*517393d9SAndrew Geissler the final image. For information on how to do this, see the 75*517393d9SAndrew Geissler ":ref:`dev-manual/securing-images:considerations specific to the openembedded build system`" 76*517393d9SAndrew Geissler section. 77*517393d9SAndrew Geissler 78*517393d9SAndrew Geissler- Ensure you have no network services listening that are not needed. 79*517393d9SAndrew Geissler 80*517393d9SAndrew Geissler- Remove any software from the image that is not needed. 81*517393d9SAndrew Geissler 82*517393d9SAndrew Geissler- Enable hardware support for secure boot functionality when your 83*517393d9SAndrew Geissler device supports this functionality. 84*517393d9SAndrew Geissler 85*517393d9SAndrew GeisslerSecurity Flags 86*517393d9SAndrew Geissler============== 87*517393d9SAndrew Geissler 88*517393d9SAndrew GeisslerThe Yocto Project has security flags that you can enable that help make 89*517393d9SAndrew Geissleryour build output more secure. The security flags are in the 90*517393d9SAndrew Geissler``meta/conf/distro/include/security_flags.inc`` file in your 91*517393d9SAndrew Geissler:term:`Source Directory` (e.g. ``poky``). 92*517393d9SAndrew Geissler 93*517393d9SAndrew Geissler.. note:: 94*517393d9SAndrew Geissler 95*517393d9SAndrew Geissler Depending on the recipe, certain security flags are enabled and 96*517393d9SAndrew Geissler disabled by default. 97*517393d9SAndrew Geissler 98*517393d9SAndrew GeisslerUse the following line in your ``local.conf`` file or in your custom 99*517393d9SAndrew Geisslerdistribution configuration file to enable the security compiler and 100*517393d9SAndrew Geisslerlinker flags for your build:: 101*517393d9SAndrew Geissler 102*517393d9SAndrew Geissler require conf/distro/include/security_flags.inc 103*517393d9SAndrew Geissler 104*517393d9SAndrew GeisslerConsiderations Specific to the OpenEmbedded Build System 105*517393d9SAndrew Geissler======================================================== 106*517393d9SAndrew Geissler 107*517393d9SAndrew GeisslerYou can take some steps that are specific to the OpenEmbedded build 108*517393d9SAndrew Geisslersystem to make your images more secure: 109*517393d9SAndrew Geissler 110*517393d9SAndrew Geissler- Ensure "debug-tweaks" is not one of your selected 111*517393d9SAndrew Geissler :term:`IMAGE_FEATURES`. 112*517393d9SAndrew Geissler When creating a new project, the default is to provide you with an 113*517393d9SAndrew Geissler initial ``local.conf`` file that enables this feature using the 114*517393d9SAndrew Geissler :term:`EXTRA_IMAGE_FEATURES` 115*517393d9SAndrew Geissler variable with the line:: 116*517393d9SAndrew Geissler 117*517393d9SAndrew Geissler EXTRA_IMAGE_FEATURES = "debug-tweaks" 118*517393d9SAndrew Geissler 119*517393d9SAndrew Geissler To disable that feature, simply comment out that line in your 120*517393d9SAndrew Geissler ``local.conf`` file, or make sure :term:`IMAGE_FEATURES` does not contain 121*517393d9SAndrew Geissler "debug-tweaks" before producing your final image. Among other things, 122*517393d9SAndrew Geissler leaving this in place sets the root password as blank, which makes 123*517393d9SAndrew Geissler logging in for debugging or inspection easy during development but 124*517393d9SAndrew Geissler also means anyone can easily log in during production. 125*517393d9SAndrew Geissler 126*517393d9SAndrew Geissler- It is possible to set a root password for the image and also to set 127*517393d9SAndrew Geissler passwords for any extra users you might add (e.g. administrative or 128*517393d9SAndrew Geissler service type users). When you set up passwords for multiple images or 129*517393d9SAndrew Geissler users, you should not duplicate passwords. 130*517393d9SAndrew Geissler 131*517393d9SAndrew Geissler To set up passwords, use the :ref:`ref-classes-extrausers` class, which 132*517393d9SAndrew Geissler is the preferred method. For an example on how to set up both root and 133*517393d9SAndrew Geissler user passwords, see the ":ref:`ref-classes-extrausers`" section. 134*517393d9SAndrew Geissler 135*517393d9SAndrew Geissler .. note:: 136*517393d9SAndrew Geissler 137*517393d9SAndrew Geissler When adding extra user accounts or setting a root password, be 138*517393d9SAndrew Geissler cautious about setting the same password on every device. If you 139*517393d9SAndrew Geissler do this, and the password you have set is exposed, then every 140*517393d9SAndrew Geissler device is now potentially compromised. If you need this access but 141*517393d9SAndrew Geissler want to ensure security, consider setting a different, random 142*517393d9SAndrew Geissler password for each device. Typically, you do this as a separate 143*517393d9SAndrew Geissler step after you deploy the image onto the device. 144*517393d9SAndrew Geissler 145*517393d9SAndrew Geissler- Consider enabling a Mandatory Access Control (MAC) framework such as 146*517393d9SAndrew Geissler SMACK or SELinux and tuning it appropriately for your device's usage. 147*517393d9SAndrew Geissler You can find more information in the 148*517393d9SAndrew Geissler :yocto_git:`meta-selinux </meta-selinux/>` layer. 149*517393d9SAndrew Geissler 150*517393d9SAndrew GeisslerTools for Hardening Your Image 151*517393d9SAndrew Geissler============================== 152*517393d9SAndrew Geissler 153*517393d9SAndrew GeisslerThe Yocto Project provides tools for making your image more secure. You 154*517393d9SAndrew Geisslercan find these tools in the ``meta-security`` layer of the 155*517393d9SAndrew Geissler:yocto_git:`Yocto Project Source Repositories <>`. 156*517393d9SAndrew Geissler 157