├── .gemspec ├── .gitignore ├── .rubocop.yml ├── CONTRIBUTING.md ├── Gemfile ├── LICENSE ├── README.md ├── Rakefile ├── backup.sh ├── build.sh ├── destroy.sh ├── docs └── uml.md ├── global.conf ├── login_duo.conf ├── restore.sh ├── script ├── bootstrap ├── build ├── functions └── test ├── spec ├── functional │ ├── admin_scripts_spec.rb │ ├── bz1099206_spec.rb │ ├── commands_spec.rb │ ├── convenience_spec.rb │ ├── locale_spec.rb │ ├── oscap_spec.rb │ ├── prohibited_packages_spec.rb │ ├── shell_shock_spec.rb │ ├── sshd_config_spec.rb │ └── users_spec.rb ├── spec_helper.rb └── unit │ ├── friction_spec.rb │ └── image_spec.rb ├── upgrade.sh ├── wercker.yml ├── wormhole ├── Dockerfile ├── README.md ├── REBUILD ├── etc │ ├── cron.allow │ ├── issue.net │ ├── pam.d │ │ ├── password-auth │ │ ├── password-auth.patch │ │ ├── sshd │ │ └── su │ ├── profile.d │ │ └── git_global.sh │ ├── skel │ │ ├── .bash_logout │ │ ├── .bash_profile │ │ └── .bashrc │ ├── ssh │ │ ├── ssh_config │ │ └── sshd_config │ └── yum.repos.d │ │ └── duo.repo └── usr │ ├── local │ ├── bin │ │ ├── jing │ │ └── trang │ └── sbin │ │ └── install-jing.sh │ ├── sbin │ ├── oscap-remediate.sh │ ├── oval-vulnerability-scan.sh │ └── start.sh │ └── share │ └── xml │ └── scap │ └── ssg │ └── fedora │ └── wormhole-devenv-xccdf.xml └── wormhole@.service /.gemspec: -------------------------------------------------------------------------------- 1 | # @see http://www.devalot.com/articles/2012/04/gem-versions.html 2 | # for a good description of gem version specs. 3 | # 4 | # Use range operators for clarity. 5 | # In general, use the range version operators (<, >, <=, >=) 6 | # instead of the pessimistic version operator (~>) when possible. 7 | # 8 | require 'English' 9 | Gem::Specification.new do |gem| 10 | gem.name = 'wormhole_test_suite' 11 | gem.homepage = 'https://github.com/jumanjiman/wormhole' 12 | gem.description = %q('Test harness for this repo') 13 | gem.summary = %q('Test harness for this repo') 14 | gem.license = 'GPLv3' 15 | 16 | gem.add_development_dependency 'docker-api', '>= 1.13.5' 17 | gem.add_development_dependency 'rake' 18 | gem.add_development_dependency 'minitest' 19 | gem.add_development_dependency 'mocha' 20 | gem.add_development_dependency 'rspec-core' 21 | gem.add_development_dependency 'rspec', '>= 3.0', '<= 4.0' 22 | gem.add_development_dependency 'rspec-expectations' 23 | gem.add_development_dependency 'rspec-mocks' 24 | gem.add_development_dependency 'rubocop', '>= 0.23.0' 25 | gem.add_development_dependency 'friction' 26 | gem.add_development_dependency 'net-ssh' 27 | 28 | gem.files = `git ls-files`.split($RS) 29 | gem.executables = gem.files.grep(%r{^bin/}).map { |f| File.basename(f) } 30 | gem.test_files = gem.files.grep(%r{^(test|spec|features)/}) 31 | gem.authors = `git log --format='%aN' | sort -u`.split($RS) 32 | gem.email = `git log --format='%aE' | sort -u`.split($RS) 33 | gem.require_paths = ['lib'] 34 | # Leave at zero 35 | gem.version = '0.0.0' 36 | end 37 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | data 2 | backup* 3 | *.tar 4 | .bundle/ 5 | Gemfile.lock 6 | jq 7 | keys 8 | -------------------------------------------------------------------------------- /.rubocop.yml: -------------------------------------------------------------------------------- 1 | --- 2 | 3 | # Avoid diff-churn! 4 | Style/TrailingComma: 5 | EnforcedStyleForMultiline: comma 6 | -------------------------------------------------------------------------------- /CONTRIBUTING.md: -------------------------------------------------------------------------------- 1 | Contributing 2 | ============ 3 | 4 | Topic branch + pull request (PR) 5 | -------------------------------- 6 | 7 | To submit a patch, fork the repo and work within 8 | a [topic branch](http://progit.org/book/ch3-4.html) of your fork. 9 | 10 | 1. Bootstrap your dev environment 11 | 12 | ```bash 13 | script/bootstrap 14 | ``` 15 | 16 | 1. Set up a remote tracking branch 17 | 18 | ```bash 19 | git checkout -b 20 | 21 | # Initial push with `-u` option sets remote tracking branch. 22 | git push -u origin 23 | ``` 24 | 25 | 1. Ensure your branch is up-to-date: 26 | 27 | ```bash 28 | git fetch --prune upstream 29 | git rebase upstream/master 30 | git push -f 31 | ``` 32 | 33 | 1. Submit a [Pull Request](https://help.github.com/articles/using-pull-requests) 34 | - Participate in [code review](https://github.com/features/projects/codereview) 35 | - Participate in [code comments](https://github.com/blog/42-commit-comments) 36 | 37 | 1. [wercker](https://app.wercker.com/#applications/54aed6aa07fa3ea415014fea) 38 | automatically runs the test harness against each pull request and push. 39 | You can also run tests locally via: 40 | 41 | ```bash 42 | script/test 43 | ``` 44 | 45 | 46 | Diff churn 47 | ---------- 48 | 49 | Please minimize diff churn to enhance git history commands. 50 | 51 | * Arrays should usually be multi-line with trailing commas. 52 | 53 | Update `.rubocop.yml` if necessary to favor minimal churn. 54 | 55 | 56 | Linear history 57 | -------------- 58 | 59 | Use `git rebase upstream/master` to update your branch. 60 | 61 | * You **must** force-push after rebasing. 62 | * We **never force-push** to master. 63 | 64 | The primary reason for this is to maintain a clean, linear history 65 | via "fast-forward" merges to master. 66 | A clean, linear history in master makes it easier 67 | to troubleshoot regressions and follow the timeline. 68 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | source 'https://rubygems.org' 3 | gemspec 4 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | Preamble 9 | 10 | The GNU General Public License is a free, copyleft license for 11 | software and other kinds of works. 12 | 13 | The licenses for most software and other practical works are designed 14 | to take away your freedom to share and change the works. By contrast, 15 | the GNU General Public License is intended to guarantee your freedom to 16 | share and change all versions of a program--to make sure it remains free 17 | software for all its users. We, the Free Software Foundation, use the 18 | GNU General Public License for most of our software; it applies also to 19 | any other work released this way by its authors. You can apply it to 20 | your programs, too. 21 | 22 | When we speak of free software, we are referring to freedom, not 23 | price. Our General Public Licenses are designed to make sure that you 24 | have the freedom to distribute copies of free software (and charge for 25 | them if you wish), that you receive source code or can get it if you 26 | want it, that you can change the software or use pieces of it in new 27 | free programs, and that you know you can do these things. 28 | 29 | To protect your rights, we need to prevent others from denying you 30 | these rights or asking you to surrender the rights. Therefore, you have 31 | certain responsibilities if you distribute copies of the software, or if 32 | you modify it: responsibilities to respect the freedom of others. 33 | 34 | For example, if you distribute copies of such a program, whether 35 | gratis or for a fee, you must pass on to the recipients the same 36 | freedoms that you received. You must make sure that they, too, receive 37 | or can get the source code. And you must show them these terms so they 38 | know their rights. 39 | 40 | Developers that use the GNU GPL protect your rights with two steps: 41 | (1) assert copyright on the software, and (2) offer you this License 42 | giving you legal permission to copy, distribute and/or modify it. 43 | 44 | For the developers' and authors' protection, the GPL clearly explains 45 | that there is no warranty for this free software. For both users' and 46 | authors' sake, the GPL requires that modified versions be marked as 47 | changed, so that their problems will not be attributed erroneously to 48 | authors of previous versions. 49 | 50 | Some devices are designed to deny users access to install or run 51 | modified versions of the software inside them, although the manufacturer 52 | can do so. This is fundamentally incompatible with the aim of 53 | protecting users' freedom to change the software. The systematic 54 | pattern of such abuse occurs in the area of products for individuals to 55 | use, which is precisely where it is most unacceptable. Therefore, we 56 | have designed this version of the GPL to prohibit the practice for those 57 | products. If such problems arise substantially in other domains, we 58 | stand ready to extend this provision to those domains in future versions 59 | of the GPL, as needed to protect the freedom of users. 60 | 61 | Finally, every program is threatened constantly by software patents. 62 | States should not allow patents to restrict development and use of 63 | software on general-purpose computers, but in those that do, we wish to 64 | avoid the special danger that patents applied to a free program could 65 | make it effectively proprietary. To prevent this, the GPL assures that 66 | patents cannot be used to render the program non-free. 67 | 68 | The precise terms and conditions for copying, distribution and 69 | modification follow. 70 | 71 | TERMS AND CONDITIONS 72 | 73 | 0. Definitions. 74 | 75 | "This License" refers to version 3 of the GNU General Public License. 76 | 77 | "Copyright" also means copyright-like laws that apply to other kinds of 78 | works, such as semiconductor masks. 79 | 80 | "The Program" refers to any copyrightable work licensed under this 81 | License. Each licensee is addressed as "you". "Licensees" and 82 | "recipients" may be individuals or organizations. 83 | 84 | To "modify" a work means to copy from or adapt all or part of the work 85 | in a fashion requiring copyright permission, other than the making of an 86 | exact copy. The resulting work is called a "modified version" of the 87 | earlier work or a work "based on" the earlier work. 88 | 89 | A "covered work" means either the unmodified Program or a work based 90 | on the Program. 91 | 92 | To "propagate" a work means to do anything with it that, without 93 | permission, would make you directly or secondarily liable for 94 | infringement under applicable copyright law, except executing it on a 95 | computer or modifying a private copy. Propagation includes copying, 96 | distribution (with or without modification), making available to the 97 | public, and in some countries other activities as well. 98 | 99 | To "convey" a work means any kind of propagation that enables other 100 | parties to make or receive copies. Mere interaction with a user through 101 | a computer network, with no transfer of a copy, is not conveying. 102 | 103 | An interactive user interface displays "Appropriate Legal Notices" 104 | to the extent that it includes a convenient and prominently visible 105 | feature that (1) displays an appropriate copyright notice, and (2) 106 | tells the user that there is no warranty for the work (except to the 107 | extent that warranties are provided), that licensees may convey the 108 | work under this License, and how to view a copy of this License. If 109 | the interface presents a list of user commands or options, such as a 110 | menu, a prominent item in the list meets this criterion. 111 | 112 | 1. Source Code. 113 | 114 | The "source code" for a work means the preferred form of the work 115 | for making modifications to it. "Object code" means any non-source 116 | form of a work. 117 | 118 | A "Standard Interface" means an interface that either is an official 119 | standard defined by a recognized standards body, or, in the case of 120 | interfaces specified for a particular programming language, one that 121 | is widely used among developers working in that language. 122 | 123 | The "System Libraries" of an executable work include anything, other 124 | than the work as a whole, that (a) is included in the normal form of 125 | packaging a Major Component, but which is not part of that Major 126 | Component, and (b) serves only to enable use of the work with that 127 | Major Component, or to implement a Standard Interface for which an 128 | implementation is available to the public in source code form. A 129 | "Major Component", in this context, means a major essential component 130 | (kernel, window system, and so on) of the specific operating system 131 | (if any) on which the executable work runs, or a compiler used to 132 | produce the work, or an object code interpreter used to run it. 133 | 134 | The "Corresponding Source" for a work in object code form means all 135 | the source code needed to generate, install, and (for an executable 136 | work) run the object code and to modify the work, including scripts to 137 | control those activities. However, it does not include the work's 138 | System Libraries, or general-purpose tools or generally available free 139 | programs which are used unmodified in performing those activities but 140 | which are not part of the work. For example, Corresponding Source 141 | includes interface definition files associated with source files for 142 | the work, and the source code for shared libraries and dynamically 143 | linked subprograms that the work is specifically designed to require, 144 | such as by intimate data communication or control flow between those 145 | subprograms and other parts of the work. 146 | 147 | The Corresponding Source need not include anything that users 148 | can regenerate automatically from other parts of the Corresponding 149 | Source. 150 | 151 | The Corresponding Source for a work in source code form is that 152 | same work. 153 | 154 | 2. Basic Permissions. 155 | 156 | All rights granted under this License are granted for the term of 157 | copyright on the Program, and are irrevocable provided the stated 158 | conditions are met. This License explicitly affirms your unlimited 159 | permission to run the unmodified Program. The output from running a 160 | covered work is covered by this License only if the output, given its 161 | content, constitutes a covered work. This License acknowledges your 162 | rights of fair use or other equivalent, as provided by copyright law. 163 | 164 | You may make, run and propagate covered works that you do not 165 | convey, without conditions so long as your license otherwise remains 166 | in force. You may convey covered works to others for the sole purpose 167 | of having them make modifications exclusively for you, or provide you 168 | with facilities for running those works, provided that you comply with 169 | the terms of this License in conveying all material for which you do 170 | not control copyright. Those thus making or running the covered works 171 | for you must do so exclusively on your behalf, under your direction 172 | and control, on terms that prohibit them from making any copies of 173 | your copyrighted material outside their relationship with you. 174 | 175 | Conveying under any other circumstances is permitted solely under 176 | the conditions stated below. Sublicensing is not allowed; section 10 177 | makes it unnecessary. 178 | 179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law. 180 | 181 | No covered work shall be deemed part of an effective technological 182 | measure under any applicable law fulfilling obligations under article 183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or 184 | similar laws prohibiting or restricting circumvention of such 185 | measures. 186 | 187 | When you convey a covered work, you waive any legal power to forbid 188 | circumvention of technological measures to the extent such circumvention 189 | is effected by exercising rights under this License with respect to 190 | the covered work, and you disclaim any intention to limit operation or 191 | modification of the work as a means of enforcing, against the work's 192 | users, your or third parties' legal rights to forbid circumvention of 193 | technological measures. 194 | 195 | 4. Conveying Verbatim Copies. 196 | 197 | You may convey verbatim copies of the Program's source code as you 198 | receive it, in any medium, provided that you conspicuously and 199 | appropriately publish on each copy an appropriate copyright notice; 200 | keep intact all notices stating that this License and any 201 | non-permissive terms added in accord with section 7 apply to the code; 202 | keep intact all notices of the absence of any warranty; and give all 203 | recipients a copy of this License along with the Program. 204 | 205 | You may charge any price or no price for each copy that you convey, 206 | and you may offer support or warranty protection for a fee. 207 | 208 | 5. Conveying Modified Source Versions. 209 | 210 | You may convey a work based on the Program, or the modifications to 211 | produce it from the Program, in the form of source code under the 212 | terms of section 4, provided that you also meet all of these conditions: 213 | 214 | a) The work must carry prominent notices stating that you modified 215 | it, and giving a relevant date. 216 | 217 | b) The work must carry prominent notices stating that it is 218 | released under this License and any conditions added under section 219 | 7. This requirement modifies the requirement in section 4 to 220 | "keep intact all notices". 221 | 222 | c) You must license the entire work, as a whole, under this 223 | License to anyone who comes into possession of a copy. This 224 | License will therefore apply, along with any applicable section 7 225 | additional terms, to the whole of the work, and all its parts, 226 | regardless of how they are packaged. This License gives no 227 | permission to license the work in any other way, but it does not 228 | invalidate such permission if you have separately received it. 229 | 230 | d) If the work has interactive user interfaces, each must display 231 | Appropriate Legal Notices; however, if the Program has interactive 232 | interfaces that do not display Appropriate Legal Notices, your 233 | work need not make them do so. 234 | 235 | A compilation of a covered work with other separate and independent 236 | works, which are not by their nature extensions of the covered work, 237 | and which are not combined with it such as to form a larger program, 238 | in or on a volume of a storage or distribution medium, is called an 239 | "aggregate" if the compilation and its resulting copyright are not 240 | used to limit the access or legal rights of the compilation's users 241 | beyond what the individual works permit. Inclusion of a covered work 242 | in an aggregate does not cause this License to apply to the other 243 | parts of the aggregate. 244 | 245 | 6. Conveying Non-Source Forms. 246 | 247 | You may convey a covered work in object code form under the terms 248 | of sections 4 and 5, provided that you also convey the 249 | machine-readable Corresponding Source under the terms of this License, 250 | in one of these ways: 251 | 252 | a) Convey the object code in, or embodied in, a physical product 253 | (including a physical distribution medium), accompanied by the 254 | Corresponding Source fixed on a durable physical medium 255 | customarily used for software interchange. 256 | 257 | b) Convey the object code in, or embodied in, a physical product 258 | (including a physical distribution medium), accompanied by a 259 | written offer, valid for at least three years and valid for as 260 | long as you offer spare parts or customer support for that product 261 | model, to give anyone who possesses the object code either (1) a 262 | copy of the Corresponding Source for all the software in the 263 | product that is covered by this License, on a durable physical 264 | medium customarily used for software interchange, for a price no 265 | more than your reasonable cost of physically performing this 266 | conveying of source, or (2) access to copy the 267 | Corresponding Source from a network server at no charge. 268 | 269 | c) Convey individual copies of the object code with a copy of the 270 | written offer to provide the Corresponding Source. This 271 | alternative is allowed only occasionally and noncommercially, and 272 | only if you received the object code with such an offer, in accord 273 | with subsection 6b. 274 | 275 | d) Convey the object code by offering access from a designated 276 | place (gratis or for a charge), and offer equivalent access to the 277 | Corresponding Source in the same way through the same place at no 278 | further charge. You need not require recipients to copy the 279 | Corresponding Source along with the object code. If the place to 280 | copy the object code is a network server, the Corresponding Source 281 | may be on a different server (operated by you or a third party) 282 | that supports equivalent copying facilities, provided you maintain 283 | clear directions next to the object code saying where to find the 284 | Corresponding Source. Regardless of what server hosts the 285 | Corresponding Source, you remain obligated to ensure that it is 286 | available for as long as needed to satisfy these requirements. 287 | 288 | e) Convey the object code using peer-to-peer transmission, provided 289 | you inform other peers where the object code and Corresponding 290 | Source of the work are being offered to the general public at no 291 | charge under subsection 6d. 292 | 293 | A separable portion of the object code, whose source code is excluded 294 | from the Corresponding Source as a System Library, need not be 295 | included in conveying the object code work. 296 | 297 | A "User Product" is either (1) a "consumer product", which means any 298 | tangible personal property which is normally used for personal, family, 299 | or household purposes, or (2) anything designed or sold for incorporation 300 | into a dwelling. In determining whether a product is a consumer product, 301 | doubtful cases shall be resolved in favor of coverage. For a particular 302 | product received by a particular user, "normally used" refers to a 303 | typical or common use of that class of product, regardless of the status 304 | of the particular user or of the way in which the particular user 305 | actually uses, or expects or is expected to use, the product. A product 306 | is a consumer product regardless of whether the product has substantial 307 | commercial, industrial or non-consumer uses, unless such uses represent 308 | the only significant mode of use of the product. 309 | 310 | "Installation Information" for a User Product means any methods, 311 | procedures, authorization keys, or other information required to install 312 | and execute modified versions of a covered work in that User Product from 313 | a modified version of its Corresponding Source. The information must 314 | suffice to ensure that the continued functioning of the modified object 315 | code is in no case prevented or interfered with solely because 316 | modification has been made. 317 | 318 | If you convey an object code work under this section in, or with, or 319 | specifically for use in, a User Product, and the conveying occurs as 320 | part of a transaction in which the right of possession and use of the 321 | User Product is transferred to the recipient in perpetuity or for a 322 | fixed term (regardless of how the transaction is characterized), the 323 | Corresponding Source conveyed under this section must be accompanied 324 | by the Installation Information. But this requirement does not apply 325 | if neither you nor any third party retains the ability to install 326 | modified object code on the User Product (for example, the work has 327 | been installed in ROM). 328 | 329 | The requirement to provide Installation Information does not include a 330 | requirement to continue to provide support service, warranty, or updates 331 | for a work that has been modified or installed by the recipient, or for 332 | the User Product in which it has been modified or installed. Access to a 333 | network may be denied when the modification itself materially and 334 | adversely affects the operation of the network or violates the rules and 335 | protocols for communication across the network. 336 | 337 | Corresponding Source conveyed, and Installation Information provided, 338 | in accord with this section must be in a format that is publicly 339 | documented (and with an implementation available to the public in 340 | source code form), and must require no special password or key for 341 | unpacking, reading or copying. 342 | 343 | 7. Additional Terms. 344 | 345 | "Additional permissions" are terms that supplement the terms of this 346 | License by making exceptions from one or more of its conditions. 347 | Additional permissions that are applicable to the entire Program shall 348 | be treated as though they were included in this License, to the extent 349 | that they are valid under applicable law. If additional permissions 350 | apply only to part of the Program, that part may be used separately 351 | under those permissions, but the entire Program remains governed by 352 | this License without regard to the additional permissions. 353 | 354 | When you convey a copy of a covered work, you may at your option 355 | remove any additional permissions from that copy, or from any part of 356 | it. (Additional permissions may be written to require their own 357 | removal in certain cases when you modify the work.) You may place 358 | additional permissions on material, added by you to a covered work, 359 | for which you have or can give appropriate copyright permission. 360 | 361 | Notwithstanding any other provision of this License, for material you 362 | add to a covered work, you may (if authorized by the copyright holders of 363 | that material) supplement the terms of this License with terms: 364 | 365 | a) Disclaiming warranty or limiting liability differently from the 366 | terms of sections 15 and 16 of this License; or 367 | 368 | b) Requiring preservation of specified reasonable legal notices or 369 | author attributions in that material or in the Appropriate Legal 370 | Notices displayed by works containing it; or 371 | 372 | c) Prohibiting misrepresentation of the origin of that material, or 373 | requiring that modified versions of such material be marked in 374 | reasonable ways as different from the original version; or 375 | 376 | d) Limiting the use for publicity purposes of names of licensors or 377 | authors of the material; or 378 | 379 | e) Declining to grant rights under trademark law for use of some 380 | trade names, trademarks, or service marks; or 381 | 382 | f) Requiring indemnification of licensors and authors of that 383 | material by anyone who conveys the material (or modified versions of 384 | it) with contractual assumptions of liability to the recipient, for 385 | any liability that these contractual assumptions directly impose on 386 | those licensors and authors. 387 | 388 | All other non-permissive additional terms are considered "further 389 | restrictions" within the meaning of section 10. If the Program as you 390 | received it, or any part of it, contains a notice stating that it is 391 | governed by this License along with a term that is a further 392 | restriction, you may remove that term. If a license document contains 393 | a further restriction but permits relicensing or conveying under this 394 | License, you may add to a covered work material governed by the terms 395 | of that license document, provided that the further restriction does 396 | not survive such relicensing or conveying. 397 | 398 | If you add terms to a covered work in accord with this section, you 399 | must place, in the relevant source files, a statement of the 400 | additional terms that apply to those files, or a notice indicating 401 | where to find the applicable terms. 402 | 403 | Additional terms, permissive or non-permissive, may be stated in the 404 | form of a separately written license, or stated as exceptions; 405 | the above requirements apply either way. 406 | 407 | 8. Termination. 408 | 409 | You may not propagate or modify a covered work except as expressly 410 | provided under this License. Any attempt otherwise to propagate or 411 | modify it is void, and will automatically terminate your rights under 412 | this License (including any patent licenses granted under the third 413 | paragraph of section 11). 414 | 415 | However, if you cease all violation of this License, then your 416 | license from a particular copyright holder is reinstated (a) 417 | provisionally, unless and until the copyright holder explicitly and 418 | finally terminates your license, and (b) permanently, if the copyright 419 | holder fails to notify you of the violation by some reasonable means 420 | prior to 60 days after the cessation. 421 | 422 | Moreover, your license from a particular copyright holder is 423 | reinstated permanently if the copyright holder notifies you of the 424 | violation by some reasonable means, this is the first time you have 425 | received notice of violation of this License (for any work) from that 426 | copyright holder, and you cure the violation prior to 30 days after 427 | your receipt of the notice. 428 | 429 | Termination of your rights under this section does not terminate the 430 | licenses of parties who have received copies or rights from you under 431 | this License. If your rights have been terminated and not permanently 432 | reinstated, you do not qualify to receive new licenses for the same 433 | material under section 10. 434 | 435 | 9. Acceptance Not Required for Having Copies. 436 | 437 | You are not required to accept this License in order to receive or 438 | run a copy of the Program. Ancillary propagation of a covered work 439 | occurring solely as a consequence of using peer-to-peer transmission 440 | to receive a copy likewise does not require acceptance. However, 441 | nothing other than this License grants you permission to propagate or 442 | modify any covered work. These actions infringe copyright if you do 443 | not accept this License. Therefore, by modifying or propagating a 444 | covered work, you indicate your acceptance of this License to do so. 445 | 446 | 10. Automatic Licensing of Downstream Recipients. 447 | 448 | Each time you convey a covered work, the recipient automatically 449 | receives a license from the original licensors, to run, modify and 450 | propagate that work, subject to this License. You are not responsible 451 | for enforcing compliance by third parties with this License. 452 | 453 | An "entity transaction" is a transaction transferring control of an 454 | organization, or substantially all assets of one, or subdividing an 455 | organization, or merging organizations. If propagation of a covered 456 | work results from an entity transaction, each party to that 457 | transaction who receives a copy of the work also receives whatever 458 | licenses to the work the party's predecessor in interest had or could 459 | give under the previous paragraph, plus a right to possession of the 460 | Corresponding Source of the work from the predecessor in interest, if 461 | the predecessor has it or can get it with reasonable efforts. 462 | 463 | You may not impose any further restrictions on the exercise of the 464 | rights granted or affirmed under this License. For example, you may 465 | not impose a license fee, royalty, or other charge for exercise of 466 | rights granted under this License, and you may not initiate litigation 467 | (including a cross-claim or counterclaim in a lawsuit) alleging that 468 | any patent claim is infringed by making, using, selling, offering for 469 | sale, or importing the Program or any portion of it. 470 | 471 | 11. Patents. 472 | 473 | A "contributor" is a copyright holder who authorizes use under this 474 | License of the Program or a work on which the Program is based. The 475 | work thus licensed is called the contributor's "contributor version". 476 | 477 | A contributor's "essential patent claims" are all patent claims 478 | owned or controlled by the contributor, whether already acquired or 479 | hereafter acquired, that would be infringed by some manner, permitted 480 | by this License, of making, using, or selling its contributor version, 481 | but do not include claims that would be infringed only as a 482 | consequence of further modification of the contributor version. For 483 | purposes of this definition, "control" includes the right to grant 484 | patent sublicenses in a manner consistent with the requirements of 485 | this License. 486 | 487 | Each contributor grants you a non-exclusive, worldwide, royalty-free 488 | patent license under the contributor's essential patent claims, to 489 | make, use, sell, offer for sale, import and otherwise run, modify and 490 | propagate the contents of its contributor version. 491 | 492 | In the following three paragraphs, a "patent license" is any express 493 | agreement or commitment, however denominated, not to enforce a patent 494 | (such as an express permission to practice a patent or covenant not to 495 | sue for patent infringement). To "grant" such a patent license to a 496 | party means to make such an agreement or commitment not to enforce a 497 | patent against the party. 498 | 499 | If you convey a covered work, knowingly relying on a patent license, 500 | and the Corresponding Source of the work is not available for anyone 501 | to copy, free of charge and under the terms of this License, through a 502 | publicly available network server or other readily accessible means, 503 | then you must either (1) cause the Corresponding Source to be so 504 | available, or (2) arrange to deprive yourself of the benefit of the 505 | patent license for this particular work, or (3) arrange, in a manner 506 | consistent with the requirements of this License, to extend the patent 507 | license to downstream recipients. "Knowingly relying" means you have 508 | actual knowledge that, but for the patent license, your conveying the 509 | covered work in a country, or your recipient's use of the covered work 510 | in a country, would infringe one or more identifiable patents in that 511 | country that you have reason to believe are valid. 512 | 513 | If, pursuant to or in connection with a single transaction or 514 | arrangement, you convey, or propagate by procuring conveyance of, a 515 | covered work, and grant a patent license to some of the parties 516 | receiving the covered work authorizing them to use, propagate, modify 517 | or convey a specific copy of the covered work, then the patent license 518 | you grant is automatically extended to all recipients of the covered 519 | work and works based on it. 520 | 521 | A patent license is "discriminatory" if it does not include within 522 | the scope of its coverage, prohibits the exercise of, or is 523 | conditioned on the non-exercise of one or more of the rights that are 524 | specifically granted under this License. You may not convey a covered 525 | work if you are a party to an arrangement with a third party that is 526 | in the business of distributing software, under which you make payment 527 | to the third party based on the extent of your activity of conveying 528 | the work, and under which the third party grants, to any of the 529 | parties who would receive the covered work from you, a discriminatory 530 | patent license (a) in connection with copies of the covered work 531 | conveyed by you (or copies made from those copies), or (b) primarily 532 | for and in connection with specific products or compilations that 533 | contain the covered work, unless you entered into that arrangement, 534 | or that patent license was granted, prior to 28 March 2007. 535 | 536 | Nothing in this License shall be construed as excluding or limiting 537 | any implied license or other defenses to infringement that may 538 | otherwise be available to you under applicable patent law. 539 | 540 | 12. No Surrender of Others' Freedom. 541 | 542 | If conditions are imposed on you (whether by court order, agreement or 543 | otherwise) that contradict the conditions of this License, they do not 544 | excuse you from the conditions of this License. If you cannot convey a 545 | covered work so as to satisfy simultaneously your obligations under this 546 | License and any other pertinent obligations, then as a consequence you may 547 | not convey it at all. For example, if you agree to terms that obligate you 548 | to collect a royalty for further conveying from those to whom you convey 549 | the Program, the only way you could satisfy both those terms and this 550 | License would be to refrain entirely from conveying the Program. 551 | 552 | 13. Use with the GNU Affero General Public License. 553 | 554 | Notwithstanding any other provision of this License, you have 555 | permission to link or combine any covered work with a work licensed 556 | under version 3 of the GNU Affero General Public License into a single 557 | combined work, and to convey the resulting work. The terms of this 558 | License will continue to apply to the part which is the covered work, 559 | but the special requirements of the GNU Affero General Public License, 560 | section 13, concerning interaction through a network will apply to the 561 | combination as such. 562 | 563 | 14. Revised Versions of this License. 564 | 565 | The Free Software Foundation may publish revised and/or new versions of 566 | the GNU General Public License from time to time. Such new versions will 567 | be similar in spirit to the present version, but may differ in detail to 568 | address new problems or concerns. 569 | 570 | Each version is given a distinguishing version number. If the 571 | Program specifies that a certain numbered version of the GNU General 572 | Public License "or any later version" applies to it, you have the 573 | option of following the terms and conditions either of that numbered 574 | version or of any later version published by the Free Software 575 | Foundation. If the Program does not specify a version number of the 576 | GNU General Public License, you may choose any version ever published 577 | by the Free Software Foundation. 578 | 579 | If the Program specifies that a proxy can decide which future 580 | versions of the GNU General Public License can be used, that proxy's 581 | public statement of acceptance of a version permanently authorizes you 582 | to choose that version for the Program. 583 | 584 | Later license versions may give you additional or different 585 | permissions. However, no additional obligations are imposed on any 586 | author or copyright holder as a result of your choosing to follow a 587 | later version. 588 | 589 | 15. Disclaimer of Warranty. 590 | 591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY 592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT 593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY 594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, 595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR 596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM 597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF 598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 599 | 600 | 16. Limitation of Liability. 601 | 602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS 604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY 605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE 606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF 607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD 608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), 609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF 610 | SUCH DAMAGES. 611 | 612 | 17. Interpretation of Sections 15 and 16. 613 | 614 | If the disclaimer of warranty and limitation of liability provided 615 | above cannot be given local legal effect according to their terms, 616 | reviewing courts shall apply local law that most closely approximates 617 | an absolute waiver of all civil liability in connection with the 618 | Program, unless a warranty or assumption of liability accompanies a 619 | copy of the Program in return for a fee. 620 | 621 | END OF TERMS AND CONDITIONS 622 | 623 | How to Apply These Terms to Your New Programs 624 | 625 | If you develop a new program, and you want it to be of the greatest 626 | possible use to the public, the best way to achieve this is to make it 627 | free software which everyone can redistribute and change under these terms. 628 | 629 | To do so, attach the following notices to the program. It is safest 630 | to attach them to the start of each source file to most effectively 631 | state the exclusion of warranty; and each file should have at least 632 | the "copyright" line and a pointer to where the full notice is found. 633 | 634 | 635 | Copyright (C) 636 | 637 | This program is free software: you can redistribute it and/or modify 638 | it under the terms of the GNU General Public License as published by 639 | the Free Software Foundation, either version 3 of the License, or 640 | (at your option) any later version. 641 | 642 | This program is distributed in the hope that it will be useful, 643 | but WITHOUT ANY WARRANTY; without even the implied warranty of 644 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 645 | GNU General Public License for more details. 646 | 647 | You should have received a copy of the GNU General Public License 648 | along with this program. If not, see . 649 | 650 | Also add information on how to contact you by electronic and paper mail. 651 | 652 | If the program does terminal interaction, make it output a short 653 | notice like this when it starts in an interactive mode: 654 | 655 | Copyright (C) 656 | This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 657 | This is free software, and you are welcome to redistribute it 658 | under certain conditions; type `show c' for details. 659 | 660 | The hypothetical commands `show w' and `show c' should show the appropriate 661 | parts of the General Public License. Of course, your program's commands 662 | might be different; for a GUI interface, you would use an "about box". 663 | 664 | You should also get your employer (if you work as a programmer) or school, 665 | if any, to sign a "copyright disclaimer" for the program, if necessary. 666 | For more information on this, and how to apply and follow the GNU GPL, see 667 | . 668 | 669 | The GNU General Public License does not permit incorporating your program 670 | into proprietary programs. If your program is a subroutine library, you 671 | may consider it more useful to permit linking proprietary applications with 672 | the library. If this is what you want to do, use the GNU Lesser General 673 | Public License instead of this License. But first, please read 674 | . 675 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Archived 2 | 3 | :warning: This git repo is superceded by **https://github.com/jumanjihouse/devenv**. 4 | 5 | 6 | ## Overview 7 | 8 | Provide docker-based development environments to support 9 | 100-500 concurrent workspaces on a single server. The idea 10 | is for developers to **edit code** and perform 11 | **light compilation or testing** within the workspace. 12 | 13 | * Serious testing is the duty of a continuous integration server. 14 | * Serious compilation is the duty of a build server. 15 | 16 | Please add any issues you find with this software 17 | to the upstream [wormhole](https://github.com/jumanjihouse/wormhole/issues). 18 | 19 | [Architectural considerations](#architectural-considerations)
20 | [OVAL vulnerability scan](#oval-vulnerability-scan)
21 | [Test harness](#test-harness)
22 | [User instructions](#user-instructions)
23 | [Admin instructions](#admin-instructions)
24 | [Contributing](https://github.com/jumanjihouse/wormhole/blob/master/CONTRIBUTING.md)
25 | [License](https://github.com/jumanjihouse/wormhole/blob/master/LICENSE)
26 | 27 | 28 | ## Architectural considerations 29 | 30 | ![admin](https://cloud.githubusercontent.com/assets/332496/3352907/edec295c-fa65-11e3-8044-f80d3f0af3c0.png) 31 | 32 | ![user](https://f.cloud.github.com/assets/332496/2528015/529d5c36-b50b-11e3-9e89-707062e47b36.png) 33 | source: [`docs/uml.md`](https://github.com/jumanjihouse/wormhole/blob/master/docs/uml.md) 34 | 35 | **Notes**: 36 | 37 | * User data lives in a data container and 38 | persists across upgrades of the app container. 39 | 40 | * sshd is restrictive: 41 | - ssh host key persists across upgrades of the app container. 42 | 43 | * Weak firewall allows: 44 | - inbound from Internet to wormhole ephemeral TCP ports 45 | - outbound from wormhole to Internet on all ports 46 | 47 | * Strong firewall allows: 48 | - inbound from wormhole IP to internal TCP 22 49 | - no outbound connections other than return traffic for inbound connections 50 | 51 | * Must be capable of running on CoreOS. Therefore no outside dependencies. 52 | 53 | * Internal infrastructure should use appropriate access control mechanisms 54 | based on risk evaluation of the wormhole. 55 | 56 | 57 | ## OVAL vulnerability scan 58 | 59 | The Red Hat Security Response Team provides OVAL definitions 60 | for all vulnerabilities (identified by CVE name) that affect RHEL or Fedora. 61 | This enables users to perform a vulnerability scan and 62 | diagnose whether the system is vulnerable. 63 | 64 | The Dockerfile in this repo adds a script to download the latest 65 | OVAL definitions from Red Hat and perform a vulnerability scan 66 | against the image. If the image has one or more known vulnerabilies, 67 | the script exits non-zero, and the `docker build` fails. 68 | 69 | Implications: 70 | 71 | * We **must resolve all known vulnerabilities** 72 | in order to successfully build an image. 73 | 74 | * The scan is time-dependent as of image build, so 75 | we should rebuild the image when Red Hat updates the OVAL feed. 76 | 77 | * The vulnerability scan is distinct from the *SCAP secure configuration scan* 78 | described [by the test harness](#test-harness). 79 | 80 | It is possible to scan an existing image: 81 | 82 | docker run --rm -t jumanjiman/wormhole /usr/sbin/oval-vulnerability-scan.sh 83 | 84 | The exact output of the vulnerability scan varies according to the 85 | latest Red Hat OVAL feed, but it looks similar to this snapshot from August 2014: 86 | 87 | -snip copious checks- 88 | 89 | RHSA-2014:1051: flash-plugin security update (Critical) 90 | oval-com.redhat.rhsa-def-20141051 91 | CVE-2014-0538 92 | CVE-2014-0540 93 | CVE-2014-0541 94 | CVE-2014-0542 95 | CVE-2014-0543 96 | CVE-2014-0544 97 | CVE-2014-0545 98 | pass 99 | 100 | RHSA-2014:1052: openssl security update (Moderate) 101 | oval-com.redhat.rhsa-def-20141052 102 | CVE-2014-3505 103 | CVE-2014-3506 104 | CVE-2014-3507 105 | CVE-2014-3508 106 | CVE-2014-3509 107 | CVE-2014-3510 108 | CVE-2014-3511 109 | pass 110 | 111 | RHSA-2014:1053: openssl security update (Moderate) 112 | oval-com.redhat.rhsa-def-20141053 113 | CVE-2014-0221 114 | CVE-2014-3505 115 | CVE-2014-3506 116 | CVE-2014-3508 117 | CVE-2014-3510 118 | pass 119 | 120 | vulnerability scan exit status 0 121 | 122 | TODO: Implement some sort of CD system to poll the OVAL feed and rebuild 123 | the image on any update. https://github.com/jumanjiman/docker-gocd may be 124 | a candidate for the solution. 125 | 126 | 127 | ## Test harness [![wercker status](https://app.wercker.com/status/690a6e04aec0e9829f88dd26c8fae27f/s/master "wercker status")](https://app.wercker.com/project/bykey/690a6e04aec0e9829f88dd26c8fae27f) 128 | 129 | RSpec documents key behaviors and assures no regressions: 130 | 131 | contributor friction 132 | there should not be any 133 | 134 | jumanjiman/wormhole 135 | should use correct docker API version 136 | image should be available 137 | image properties 138 | should expose ssh port and only ssh port 139 | should have volume /home/user 140 | should have volume /media/state/etc/ssh 141 | 142 | admin scripts 143 | given user handle="booga" 144 | everybody knows pubkey 145 | booga knows privkey 146 | `build.sh $handle "$pubkey"` creates wormhole from 2 containers 147 | "booga-data" is a persistent read-write container 148 | should exist 149 | should be stopped 150 | should be created from busybox 151 | should export /home/user volume read-write 152 | should export /media/state/etc/ssh volume read-write 153 | should not mount any volumes 154 | "booga" is a read-only app container 155 | should exist 156 | should be running 157 | should run unprivileged 158 | should be created from jumanjiman/wormhole 159 | should use volumes from booga-data 160 | should have hostname wormhole.example.com 161 | should be limited to 512 MiB RAM 162 | `docker logs` should show sshd running on sshd port 163 | should expose internal sshd port and only sshd port 164 | should map internal sshd port to an outside ephemeral port 165 | 166 | BZ1099206 (slow test) 167 | home directory should exist 168 | go get should work 169 | 170 | user convenience 171 | man -k returns results 172 | locate returns the path for issue.net 173 | 174 | shell-shock 175 | should resolve CVE-014-6271 176 | should resolve CVE-014-7169 177 | 178 | locale archive 179 | supports C 180 | supports POSIX 181 | supports en_US.utf8 182 | supports en_US.UTF-8 183 | 184 | SCAP secure configuration checks (slow test) 185 | should pass all tests 186 | /etc/securetty should be a zero-size file 187 | 188 | prohibited packages 189 | should not have at installed 190 | should not have prelink installed 191 | should not have sudo installed 192 | 193 | prohibited commands 194 | should not have the at command 195 | should not have the crond command 196 | should not have the crontab command 197 | should not have the /usr/sbin/prelink command 198 | 199 | sshd config 200 | auth 201 | should use privilege separation 202 | should use pam 203 | should allow pubkeyauthentication 204 | should deny passwordauthentication 205 | should deny gssapiauthentication 206 | should deny kerberosauthentication 207 | should deny challengeresponseauthentication 208 | should use strong, perfect forward secrecy for key exchange 209 | tunnels and forwarding 210 | should deny ssh tunnels 211 | should deny TCP forwarding 212 | should deny X11 forwarding 213 | should deny gateway ports 214 | Common Configuration Enumeration (CCE) 215 | CCE-3660-8 Disable remote ssh from accounts with empty passwords 216 | CCE-3845-5 idle timeout interval should be set appropriately 217 | CCE-4325-7 Disable SSH protocol version 1 218 | CCE-4370-3 Disable SSH host-based authentication 219 | CCE-4387-7 Disable root login via SSH 220 | CCE-4431-3 SSH warning banner should be enabled 221 | CCE-4475-0 Disable emulation of rsh command through sshd 222 | CCE-14061-6 "keep alive" msg count should be set appropriately 223 | CCE-14491-5 Use appropriate ciphers for SSH 224 | CCE-14716-5 Users should not be allowed to set env options 225 | obscurity 226 | should hide patch level 227 | 228 | users with interactive shells 229 | should only include "root" and "user" 230 | su 231 | "user" cannot su 232 | 233 | Finished in 1 minute 6.35 seconds (files took 0.45472 seconds to load) 234 | 61 examples, 0 failures 235 | 236 | 237 | The OpenSCAP secure configuration test shown above uses a 238 | [tailoring file](wormhole/wormhole-devenv-xccdf.xml) 239 | to adjust the upstream checks. 240 | It expands to this inside the container: 241 | 242 | Title gpgcheck Enabled In Main Yum Configuration 243 | Rule ensure_gpgcheck_globally_activated 244 | Result pass 245 | 246 | Title gpgcheck Enabled For All Yum Package Repositories 247 | Rule ensure_gpgcheck_never_disabled 248 | Result pass 249 | 250 | Title Shared Library Files Have Restrictive Permissions 251 | Rule file_permissions_library_dirs 252 | Result pass 253 | 254 | Title Shared Library Files Have Root Ownership 255 | Rule file_ownership_library_dirs 256 | Result pass 257 | 258 | Title System Executables Have Restrictive Permissions 259 | Rule file_permissions_binary_dirs 260 | Result pass 261 | 262 | Title System Executables Have Root Ownership 263 | Rule file_ownership_binary_dirs 264 | Result pass 265 | 266 | Title Direct root Logins Not Allowed 267 | Rule no_direct_root_logins 268 | Result notchecked 269 | 270 | Title Virtual Console Root Logins Restricted 271 | Rule securetty_root_login_console_only 272 | Result pass 273 | 274 | Title Serial Port Root Logins Restricted 275 | Rule restrict_serial_port_logins 276 | Result pass 277 | 278 | Title Only Root Has UID 0 279 | Rule no_uidzero_except_root 280 | Result pass 281 | 282 | Title Log In to Accounts With Empty Password Impossible 283 | Rule no_empty_passwords 284 | Result pass 285 | 286 | Title Password Hashes For Each Account Shadowed 287 | Rule no_hashes_outside_shadow 288 | Result pass 289 | 290 | Title netrc Files Do Not Exist 291 | Rule no_netrc_files 292 | Result pass 293 | 294 | Title SSH Root Login Disabled 295 | Rule sshd_disable_root_login 296 | Result pass 297 | 298 | Title SSH Access via Empty Passwords Disabled 299 | Rule sshd_disable_empty_passwords 300 | Result pass 301 | 302 | Title SSH Idle Timeout Interval Used 303 | Rule sshd_set_idle_timeout 304 | Result pass 305 | 306 | Title SSH Client Alive Count Used 307 | Rule sshd_set_keepalive 308 | Result pass 309 | 310 | 311 | ## User instructions 312 | 313 | New containers begin life with a git-suitable 314 | [`~/.bashrc`](https://github.com/ISEexchange/docker-wormhole/blob/master/.bashrc). 315 | This is only the initial bashrc; you can modify it at any time. 316 | 317 | Inside the container, your user account is literally named `user`. 318 | That means, with default build options, your prompt inside the container is: 319 | 320 | user@wormhole:~$ 321 | 322 | Connect to your container with info provided by admin: 323 | 324 | ssh -i path/to/privkey -p user@ 325 | 326 | 327 | ## Admin instructions 328 | 329 | ### Edit global configuration 330 | 331 | Clone this repo, then inspect and optionally modify `global.conf`. 332 | When you build a user box for the first time, the build script 333 | copies `global.conf` into `/etc/wormhole/global.conf`. 334 | 335 | 336 | ### Edit duo configuration 337 | 338 | This step is optional. The default configuration **does not use Duo**. 339 | If you want to use Duo Security for multi-factor authentication, 340 | you must edit both `global.conf` and `login_duo.conf`. 341 | 342 | * When you build your first user box (see below), these two files 343 | are copied into `/etc/wormhole/`. 344 | 345 | * If you modify `/etc/wormhole/*.conf`, you must restart the user 346 | app container(s). 347 | 348 | 349 | ### Build a user box 350 | 351 | Use the build script with a unique user id (such as github handle) 352 | and the user ssh pubkey to create a runtime container: 353 | 354 | user=jumanjiman 355 | pubkey="ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEArSm80/8UD/eMolUXU3j6geyNrxthnQxbE4dpwRhXU+F6fbQG+wk9SdWev9NcLLWg9a4zBUSMJUXrrU/8ik3WshSpZpqQary4ZiFFQKgSfYriouchc20S3wwFQZcbOJgH5t5wgGeNaDMzc2GRFhqbuuBiBBF+W5llk0X9CGE1o1iAlyVPAn4UfrJ4//5OXMhYwmU+fO9df3y5Kpn/0SY/lRwWuZeVVIXC+nZcFYXNzPyBVTNEooOXLVXivddtU82jfp65ggTMdLfUafZqia1/smfWQP23lU8F4ySayAOa1lhXXvrGtpxl3lu7vaSvdEg7+F4YaIhxnWZqt769joDraw== pmorgan@github" 356 | 357 | ./build.sh $user "$pubkey" 358 | 359 | :warning: The build script attempts to fetch the github user's 360 | ssh pubkeys and place them into the data container as authorized keys. 361 | This is *really* bad if you create a devenv for somebody based on 362 | a name that is *not* their github handle and the name is a valid 363 | github handle for somebody else! 364 | 365 | A runtime container should be up on a random ssh port: 366 | 367 | $ docker ps 368 | 369 | CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES 370 | 689479673e8e jumanjiman:latest /bin/sh -c /usr/sbin About an hour ago Up About an hour 0.0.0.0:49153->22/tcp jumanjiman 371 | 372 | The build script depends on systemd and enables a "wormhole@" 373 | service to start at boot-time for the container you just created and 374 | persists the port as an environment variable in `/etc/wormhole/.conf`. 375 | For example: If the username is jumanjiman, you can run 376 | `sudo systemctl status wormhole@jumanjiman` to see: 377 | 378 | ● wormhole@jumanjiman.service - jumanjiman app container 379 | Loaded: loaded (/etc/systemd/system/wormhole@.service; enabled) 380 | Active: active (running) since Wed 2014-06-18 14:08:05 UTC; 3h 18min ago 381 | Main PID: 701 (docker) 382 | CGroup: /system.slice/system-wormhole.slice/wormhole@jumanjiman.service 383 | └─701 /usr/bin/docker run --rm -t -m 512m --volumes-from jumanjiman-data -p 49153:22 -h wormhole.example.com --name jumanjiman... 384 | 385 | 386 | Jun 18 14:08:05 ip-192-168-254-21 bash[478]: jumanjiman 387 | Jun 18 14:08:05 ip-192-168-254-21 systemd[1]: Started jumanjiman app container. 388 | Jun 18 14:08:09 ip-192-168-254-21 docker[701]: Server listening on 0.0.0.0 port 22. 389 | Jun 18 14:08:09 ip-192-168-254-21 docker[701]: Server listening on :: port 22. 390 | 391 | :warning: The default `global.conf` limits each app container to 512 MiB memory. 392 | You can override this for a single user in `/etc/wormhole/.conf`. 393 | 394 | You can view the current limit for a container via the sys filesystem. 395 | For example, here is a container that was started with a 1 MiB limit: 396 | 397 | $ cat /sys/fs/cgroup/memory/lxc//memory.limit_in_bytes 398 | 1048576 399 | 400 | If a PID inside a container gets killed due to the memory limit, 401 | you can view details in `dmesg` output. 402 | 403 | 404 | ### Backup 405 | 406 | Create a local file called `jumanjiman-data.tar` with contents of 407 | user data container. 408 | 409 | ./backup.sh jumanjiman 410 | 411 | 412 | ### Restore user data container from backup 413 | 414 | ./restore.sh jumanjiman 415 | 416 | 417 | ### Upgrade user app container 418 | 419 | Rebuild the `jumanjiman/wormhole` image as described above, then... 420 | 421 | ./upgrade.sh jumanjiman 422 | 423 | 424 | ### Destroy a user app+data container 425 | 426 | Backup, then discard both the app and data containers for a user. 427 | 428 | ./destroy.sh jumanjiman 429 | 430 | 431 | ### Build an image for the app container 432 | 433 | This image serves as a template for an app container.
434 | You can build the image locally: 435 | 436 | script/build 437 | 438 | Trigger a rebuild-and-test cycle to get latest updates: 439 | 440 | cd wormhole/ 441 | date > REBUILD 442 | git add REBUILD 443 | git commit -m 'test build with latest package updates' 444 | # Open pull request. 445 | 446 | :warning: Use CoreOS to build image. 447 | 448 | Fedora kernel on DigitalOcean 449 | has an older LXC implementation that leads to inconsistent builds. 450 | For example, it sometimes builds the base image with bad perms on 451 | `/var` and other directories that *must* be `0755`. 452 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | # vim: set ts=2 sw=2 ai et: 3 | 4 | # Does the current user have root privileges? 5 | # 6 | # @return [Boolean] true if user can exercise root privileges; 7 | # false if user does not have privileges OR we're on a 8 | # non-posix platform 9 | def got_root? 10 | # attempt to exercise privilege 11 | Process::Sys.setuid(0) 12 | true 13 | rescue Errno::EPERM 14 | false 15 | end 16 | 17 | abort 'Must not run as root' if got_root? 18 | 19 | require 'bundler/setup' 20 | require 'bundler/settings' 21 | require 'rspec/core/rake_task' 22 | require 'rubocop/rake_task' 23 | require 'fileutils' 24 | 25 | task default: [:help] 26 | 27 | desc 'Display the list of available rake tasks' 28 | task :help do 29 | system('rake -T') 30 | end 31 | 32 | RuboCop::RakeTask.new 33 | 34 | # Run unit tests before functional tests. 35 | desc 'Run rspec tests' 36 | task spec_standalone: [ 37 | :validate_bundle, 38 | :unit, 39 | :functional, 40 | ] 41 | 42 | RSpec::Core::RakeTask.new(:unit) do |t| 43 | t.pattern = 'spec/unit/**/*_spec.rb' 44 | end 45 | 46 | RSpec::Core::RakeTask.new(:functional) do |t| 47 | t.pattern = 'spec/functional/**/*_spec.rb' 48 | end 49 | 50 | task :validate_bundle do 51 | begin 52 | require 'docker' 53 | Docker.validate_version! 54 | rescue Docker::Error::VersionError 55 | abort '[ERROR] docker-api gem is incompatible with this version of Docker' 56 | end 57 | end 58 | -------------------------------------------------------------------------------- /backup.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Import smitty. 5 | source script/functions 6 | 7 | user=$1 8 | if test -z $user; then 9 | echo "Usage: $(basename $0) " 2> /dev/null 10 | exit 1 11 | fi 12 | 13 | smitty docker run --rm --volumes-from $user-data -v $(pwd):/backup busybox tar cvf /backup/$user-data.tar /home/user /media/state/etc/ssh 14 | -------------------------------------------------------------------------------- /build.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | set -o noclobber 4 | 5 | # Import smitty. 6 | source script/functions 7 | 8 | user=$1 9 | pubkey=$2 10 | if test -z $user ; then 11 | echo "Usage: $(basename $0) " 2> /dev/null 12 | exit 1 13 | fi 14 | 15 | global_config=/etc/wormhole/global.conf 16 | 17 | sudo mkdir -p /etc/wormhole || : 18 | [[ -r $global_config ]] || sudo cp -f global.conf /etc/wormhole/ 19 | source $global_config 20 | 21 | duo_config=/etc/wormhole/login_duo.conf 22 | [[ -r $duo_config ]] || sudo cp -f login_duo.conf /etc/wormhole/ 23 | 24 | rm -f data 25 | cat >> data < /dev/null || : 34 | cat data | docker build --rm -t data - 35 | 36 | # create tiny data container named $user-data 37 | smitty docker rm $user-data 2> /dev/null || : 38 | smitty docker run -v /home/user -v /media/state/etc/ssh --name $user-data busybox true 39 | 40 | # remove the data image since we no longer need it 41 | smitty docker rmi data || : 42 | 43 | # add contents of /etc/skel into data container 44 | smitty docker run --rm --volumes-from $user-data -u root $base_image cp /etc/skel/.bash* /home/user 45 | 46 | # fix ownership of homedir 47 | smitty docker run --rm --volumes-from $user-data -u root $base_image chown -R user:user /home/user 48 | 49 | # add ssh keys 50 | smitty docker run --rm --volumes-from $user-data -u user $base_image mkdir -p /home/user/.ssh 51 | smitty docker run --rm --volumes-from $user-data -u user $base_image chmod 0700 /home/user/.ssh 52 | smitty docker run --rm --volumes-from $user-data -u user $base_image /bin/bash -c "echo $pubkey >> /home/user/.ssh/authorized_keys" 53 | smitty docker run --rm --volumes-from $user-data -u user $base_image chmod 0600 /home/user/.ssh/authorized_keys 54 | smitty curl --silent -m 10 -O https://api.github.com/users/${user}/keys 55 | if [[ $? -eq 0 ]]; then 56 | [[ -x ./jq ]] || curl -O http://stedolan.github.io/jq/download/linux64/jq 57 | chmod 0755 ./jq 58 | old_ifs=$IFS 59 | IFS=$'\n' 60 | for pubkey in $(./jq -r '.[].key' keys ); do 61 | smitty docker run --rm --volumes-from $user-data -u user $base_image /bin/bash -c "echo $pubkey >> /home/user/.ssh/authorized_keys" 62 | done 63 | IFS=$old_ifs 64 | rm -f keys 65 | fi 66 | 67 | # create a container from the user image 68 | smitty docker run -d -t -m $max_ram --volumes-from $user-data -P -h $sandbox_hostname --name $user $base_image 69 | port=$(docker port $user 22 | cut -d: -f2) 70 | smitty docker stop $user 71 | smitty docker rm $user 72 | 73 | # Make the container persistent. 74 | smitty sudo cp -f wormhole@.service /etc/systemd/system/ 75 | echo -e "PORT=$port\n" | sudo tee /etc/wormhole/${user}.conf 76 | smitty sudo systemctl enable wormhole@$user 77 | smitty sudo systemctl start wormhole@$user 78 | smitty sleep 2 79 | smitty sudo systemctl status wormhole@$user 80 | -------------------------------------------------------------------------------- /destroy.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # Import smitty. 4 | source script/functions 5 | 6 | user=$1 7 | 8 | test -z $user && err "Usage: $(basename $0) " 9 | test -f $user-data.tar && err $user-data.tar already exists 10 | smitty sudo systemctl stop wormhole@$user 11 | smitty sudo systemctl disable wormhole@$user 12 | smitty ./backup.sh $user 13 | smitty docker rm $user-data 14 | smitty docker rm $user 15 | smitty sudo rm -f /etc/wormhole/${user}.conf 16 | -------------------------------------------------------------------------------- /docs/uml.md: -------------------------------------------------------------------------------- 1 | # UML architecture diagrams 2 | 3 | This is the source for creating diagrams via 4 | http://bramp.github.io/js-sequence-diagrams/ 5 | 6 | ## User 7 | 8 | ``` 9 | Participant Internet 10 | Participant Weak\nFirewall 11 | Participant Wormhole 12 | Participant Strong\nFirewall 13 | Participant Internal\nInfrastructure 14 | Participant Internal\nAAA 15 | 16 | Internet->Wormhole: user ssh via 2fa 17 | note over Wormhole: unpriviliged\ncontainerized\nsandbox session 18 | Wormhole->Internet: git fetch/push 19 | Wormhole->Internet: bundle install 20 | Wormhole->Internet: curl ... 21 | Wormhole->Internal\nInfrastructure: ssh via internal mechanism(s) 22 | Internal\nInfrastructure->Internal\nAAA: check auth (pass/fail) 23 | note over Internal\nInfrastructure: user session 24 | Internal\nInfrastructure->Strong\nFirewall: (X) deny outbound 25 | ``` 26 | -------------------------------------------------------------------------------- /global.conf: -------------------------------------------------------------------------------- 1 | # systemd-style config to be sourced by scripts. 2 | # Note that bash-style variable expansion is not supported. 3 | # See systemd.exec(5) for format. 4 | 5 | # What image do we use to create app containers? 6 | base_image="jumanjiman/wormhole:latest" 7 | 8 | # What hostname does user see inside container? 9 | sandbox_hostname="wormhole.example.com" 10 | 11 | # How much RAM does each user get? 12 | max_ram="512m" 13 | 14 | # Should we use duo for multi-factor auth? 15 | # Anything other than "true" is false. 16 | # 17 | # Learn how to configure duo at 18 | # https://www.duosecurity.com/docs/duounix 19 | DUO=false 20 | -------------------------------------------------------------------------------- /login_duo.conf: -------------------------------------------------------------------------------- 1 | # If these values are blank, login_duo allows login and complains: 2 | # bash-4.2# /usr/sbin/login_duo 3 | # Missing host, ikey, or skey in /etc/duo/login_duo.conf 4 | # -bash-4.2# 5 | [duo] 6 | ; Duo integration key 7 | ikey = 8 | 9 | ; Duo secret key 10 | skey = 11 | 12 | ; Duo API hostname 13 | host = 14 | -------------------------------------------------------------------------------- /restore.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Import smitty. 5 | source script/functions 6 | 7 | user=$1 8 | if test -z $user; then 9 | echo "Usage: $(basename $0) " 2> /dev/null 10 | exit 1 11 | fi 12 | 13 | smitty docker run -v /home/user -v /media/state/etc/ssh --name $user-data busybox true 14 | smitty docker run --rm --volumes-from $user-data -v $(pwd):/backup busybox tar xvf /backup/$user-data.tar 15 | -------------------------------------------------------------------------------- /script/bootstrap: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # Import smitty. 5 | . script/functions 6 | 7 | git remote show upstream &> /dev/null || smitty git remote add upstream https://github.com/jumanjihouse/wormhole.git 8 | 9 | rm -f Gemfile.lock 10 | smitty bundle update 2> /dev/null || smitty bundle install --path=~/.bundle 11 | -------------------------------------------------------------------------------- /script/build: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | . script/functions 5 | 6 | pushd wormhole 2> /dev/null 7 | smitty docker build --rm -t jumanjiman/wormhole:${short_hash} . 8 | smitty docker tag jumanjiman/wormhole:${short_hash} jumanjiman/wormhole:latest 9 | popd 2> /dev/null 10 | -------------------------------------------------------------------------------- /script/functions: -------------------------------------------------------------------------------- 1 | smitty() { 2 | echo; echo 3 | echo -e "[INFO] $@" 4 | "$@" 5 | } 6 | 7 | err() { 8 | echo "[ERROR] $@" >&2 9 | exit 1 10 | } 11 | 12 | short_hash=$(git rev-parse --short HEAD) 13 | -------------------------------------------------------------------------------- /script/test: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | set -e 3 | 4 | . script/functions 5 | 6 | smitty bundle exec rake rubocop 7 | smitty bundle exec rake spec_standalone 8 | -------------------------------------------------------------------------------- /spec/functional/admin_scripts_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'admin scripts' do 5 | describe "given user handle=\"#{handle}\"" do 6 | it 'everybody knows pubkey' do 7 | File.exist?(@pubkey).should be_truthy 8 | end 9 | 10 | it "#{handle} knows privkey" do 11 | File.exist?(@privkey).should be_truthy 12 | end 13 | end 14 | 15 | describe '`build.sh $handle "$pubkey"` creates wormhole from 2 containers' do 16 | describe "\"#{handle}-data\" is a persistent read-write container" do 17 | before :context do 18 | @config = @data.json['Config'] 19 | @hostconfig = @data.json['HostConfig'] 20 | @state = @data.json['State'] 21 | pp @data.json unless @config && @state 22 | end 23 | 24 | it 'should exist' do 25 | @data.should_not be_nil 26 | end 27 | 28 | it 'should be stopped' do 29 | @state['Running'].should be_falsy 30 | end 31 | 32 | it 'should be created from busybox' do 33 | id = @config['Image'].split(':').first 34 | id.should == 'busybox' 35 | end 36 | 37 | it 'should export /home/user volume read-write' do 38 | @config['Volumes'].keys.include?('/home/user').should be_truthy 39 | @data.json['VolumesRW'].key?('/home/user').should be_truthy 40 | @data.json['VolumesRW']['/home/user'].should be_truthy 41 | end 42 | 43 | it 'should export /media/state/etc/ssh volume read-write' do 44 | @data.json['VolumesRW'].key?('/media/state/etc/ssh').should be_truthy 45 | @data.json['VolumesRW']['/media/state/etc/ssh'].should be_truthy 46 | end 47 | 48 | it 'should not mount any volumes' do 49 | @config['Volumes'].each { |_k, v| v.should be_empty } 50 | @hostconfig['VolumesFrom'].should be_nil 51 | end 52 | end 53 | 54 | describe "\"#{handle}\" is a read-only app container" do 55 | before :context do 56 | @config = @app.json['Config'] 57 | @hostconfig = @app.json['HostConfig'] 58 | @state = @app.json['State'] 59 | pp @app.json unless @config && @state 60 | end 61 | 62 | it 'should exist' do 63 | @app.should_not be_nil 64 | end 65 | 66 | it 'should be running' do 67 | @state['Running'].should be_truthy 68 | end 69 | 70 | it 'should run unprivileged' do 71 | priv = @app.json['HostConfig']['Privileged'] 72 | priv.should be_falsy 73 | end 74 | 75 | it 'should be created from jumanjiman/wormhole' do 76 | id = @config['Image'].split(':').first 77 | id.should == 'jumanjiman/wormhole' 78 | end 79 | 80 | it "should use volumes from #{handle}-data" do 81 | @hostconfig['VolumesFrom'].should =~ ["#{handle}-data"] 82 | end 83 | 84 | it 'should have hostname wormhole.example.com' do 85 | fqdn = @config['Hostname'] + '.' + @config['Domainname'] 86 | fqdn.should == 'wormhole.example.com' 87 | end 88 | 89 | it 'should be limited to 512 MiB RAM' do 90 | limit = 512 * 1024 * 1024 91 | @config['Memory'].should == limit 92 | end 93 | 94 | it '`docker logs` should show sshd running on sshd port' do 95 | sleep 2 # allow for startup time 96 | output = `docker logs #{handle}` 97 | output.should =~ /Server listening on 0.0.0.0 port 22/ 98 | end 99 | 100 | it 'should expose internal sshd port and only sshd port' do 101 | @app.json['NetworkSettings']['Ports'].keys.should =~ ['22/tcp'] 102 | end 103 | 104 | it 'should map internal sshd port to an outside ephemeral port' do 105 | port = @app.json['NetworkSettings']['Ports']['22/tcp'][0]['HostPort'] 106 | port.to_i.should > 1024 107 | end 108 | end 109 | end 110 | end 111 | -------------------------------------------------------------------------------- /spec/functional/bz1099206_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | # https://github.com/jumanjiman/bz1099206 5 | # 6 | # We need golang-1.2.2-22.fc20 or later: 7 | # https://admin.fedoraproject.org/updates/FEDORA-2014-9424/golang-1.2.2-22.fc20 8 | describe 'BZ1099206 (slow test)' do 9 | it 'home directory should exist' do 10 | output = ssh('ls -d /home/user') 11 | output.should =~ %r{^/home/user$} 12 | end 13 | 14 | it 'go get should work' do 15 | go_cmd = [ 16 | 'export GOPATH=/home/user/gocode', 17 | '/usr/bin/go get github.com/epeli/hooktftp', 18 | 'ls /home/user/gocode/bin/hooktftp', 19 | ].join(';') 20 | output = ssh(go_cmd) 21 | output.should =~ %r{^/home/user/gocode/bin/hooktftp$} 22 | end 23 | end 24 | -------------------------------------------------------------------------------- /spec/functional/commands_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'useful commands' do 5 | commands = %w( 6 | docker 7 | wget 8 | ) 9 | 10 | commands.each do |cmd| 11 | it '${cmd} is in user path' do 12 | output = ssh("which #{cmd}").split($RS).last.chomp 13 | output.should =~ %r{^.*bin/#{cmd}$} 14 | end 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /spec/functional/convenience_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'user convenience' do 5 | it 'man -k returns results' do 6 | output = ssh('man -k git').split($RS) 7 | output.length.should >= 10 8 | end 9 | 10 | # @note This rspec also asserts that /etc/issue.net is available for sshd. 11 | it 'locate returns the path for issue.net' do 12 | output = ssh('locate issue.net') 13 | output.should =~ %r{^/etc/issue.net$} 14 | end 15 | end 16 | -------------------------------------------------------------------------------- /spec/functional/locale_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'locale archive' do 5 | locales = [ 6 | 'C', 7 | 'POSIX', 8 | 'en_US.utf8', 9 | ] 10 | 11 | before :all do 12 | @all_locales = ssh('locale -a') 13 | end 14 | 15 | locales.each do |locale| 16 | it "supports #{locale}" do 17 | output = ssh("export LANG=#{locale}; locale -a 2>&1") 18 | output.should_not =~ /Cannot/ 19 | @all_locales.should =~ /^#{locale}$/ 20 | end 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/functional/oscap_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'SCAP secure configuration checks (slow test)' do 5 | it 'should pass all tests' do 6 | pending 'disable this check for now' 7 | cmds = ' 8 | cd /usr/share/xml/scap/ssg/fedora/ 9 | oscap xccdf eval --profile xccdf_wormhole_profile_devenv \ 10 | --tailoring-file wormhole-devenv-xccdf.xml \ 11 | --cpe ssg-fedora-cpe-dictionary.xml \ 12 | ssg-fedora-xccdf.xml && echo OK 13 | ' 14 | ssh(cmds).should match(/^OK$/) 15 | end 16 | 17 | # Why does oscap skip this check? 18 | it '/etc/securetty should be a zero-size file' do 19 | cmd = "stat --format='%s' /etc/securetty" 20 | ssh(cmd).should match(/^0$/) 21 | end 22 | end 23 | -------------------------------------------------------------------------------- /spec/functional/prohibited_packages_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'prohibited packages' do 5 | prohibited_packages = %w( 6 | at 7 | prelink 8 | sudo 9 | ) 10 | 11 | prohibited_packages.each do |package| 12 | it "should not have #{package} installed" do 13 | output = ssh("rpm -q #{package} 2>&1") 14 | output.should =~ /^package #{package} is not installed$/ 15 | end 16 | end 17 | end 18 | 19 | # Multiple packages can provide some commands, so 20 | # we check for the commands, too. 21 | # Multiple CCE's recommend restricting at and cron. 22 | describe 'prohibited commands' do 23 | prohibited_commands = %w( 24 | at 25 | crond 26 | crontab 27 | /usr/sbin/prelink 28 | ) 29 | 30 | prohibited_commands.each do |cmd| 31 | it "should not have the #{cmd} command" do 32 | output = ssh("which #{cmd} 2>&1") 33 | # `which' splits the cmd into path and basename components, 34 | # such as `which: no prelink in (/usr/sbin)' 35 | cmd = cmd.split('/').last 36 | output.should =~ /no #{cmd} in/ 37 | end 38 | end 39 | end 40 | -------------------------------------------------------------------------------- /spec/functional/shell_shock_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'shell-shock' do 5 | # http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-6271 6 | it 'should resolve CVE-2014-6271' do 7 | cmd = %!env X='() { :;} ; echo busted' /bin/sh -c "echo completed" 2>&1! 8 | output = ssh(cmd) 9 | output.should_not =~ /busted/ 10 | end 11 | 12 | # http://web.nvd.nist.gov/view/vuln/detail?vulnId=CVE-2014-7169 13 | it 'should resolve CVE-2014-7169' do 14 | cmd = %!env X='() { (a)=>\' sh -c "echo date" 2> /dev/null; cat echo 2>&1! 15 | output = ssh(cmd) 16 | output.should =~ /No such file or directory/ 17 | end 18 | end 19 | -------------------------------------------------------------------------------- /spec/functional/sshd_config_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'sshd config' do 5 | before :context do 6 | @config = ssh('/usr/sbin/sshd -T 2> /dev/null') 7 | end 8 | 9 | describe 'auth' do 10 | allow_auth = %w( 11 | pubkeyauthentication 12 | ) 13 | 14 | deny_auth = %w( 15 | passwordauthentication 16 | gssapiauthentication 17 | kerberosauthentication 18 | challengeresponseauthentication 19 | ) 20 | 21 | allow_kex = %w( 22 | curve25519-sha256@libssh.org 23 | diffie-hellman-group-exchange-sha256 24 | ) 25 | 26 | it 'should use privilege separation' do 27 | @config.should =~ /^useprivilegeseparation yes\r*$/ 28 | end 29 | 30 | it 'should use pam' do 31 | @config.should =~ /^usepam 1\r*$/ 32 | end 33 | 34 | allow_auth.each do |allow| 35 | it "should allow #{allow}" do 36 | @config.should =~ /^#{allow} yes\r*$/ 37 | end 38 | end 39 | 40 | deny_auth.each do |deny| 41 | it "should deny #{deny}" do 42 | @config.should =~ /^#{deny} no\r*$/ 43 | end 44 | end 45 | 46 | it 'should use strong, perfect forward secrecy for key exchange' do 47 | @config.should =~ /^kexalgorithms #{allow_kex.join(',')}\r*$/ 48 | end 49 | end 50 | 51 | describe 'tunnels and forwarding' do 52 | it 'should deny ssh tunnels' do 53 | @config.should =~ /^permittunnel no\r*$/ 54 | end 55 | 56 | it 'should deny TCP forwarding' do 57 | @config.should =~ /^allowtcpforwarding no\r*$/ 58 | end 59 | 60 | # @note I could be convinced to allow X11 forwarding. 61 | it 'should deny X11 forwarding' do 62 | @config.should =~ /^x11forwarding no\r*$/ 63 | end 64 | 65 | it 'should deny gateway ports' do 66 | @config.should =~ /^gatewayports no\r*$/ 67 | end 68 | end 69 | 70 | describe 'Common Configuration Enumeration (CCE)' do 71 | it 'CCE-3660-8 Disable remote ssh from accounts with empty passwords' do 72 | @config.should =~ /^permitemptypasswords no\r*$/ 73 | end 74 | 75 | it 'CCE-3845-5 idle timeout interval should be set appropriately' do 76 | @config.should =~ /^clientaliveinterval 900\r*$/ 77 | end 78 | 79 | it 'CCE-4325-7 Disable SSH protocol version 1' do 80 | @config.should =~ /^protocol 2\r*$/ 81 | @config.should_not =~ /^protocol 1\r*$/ 82 | end 83 | 84 | it 'CCE-4370-3 Disable SSH host-based authentication' do 85 | @config.should =~ /^hostbasedauthentication no\r*$/ 86 | end 87 | 88 | it 'CCE-4387-7 Disable root login via SSH' do 89 | @config.should =~ /^permitrootlogin no\r*$/ 90 | end 91 | 92 | it 'CCE-4431-3 SSH warning banner should be enabled' do 93 | @config.should =~ %r{^banner /etc/issue\.net\r*$} 94 | end 95 | 96 | it 'CCE-4475-0 Disable emulation of rsh command through sshd' do 97 | @config.should =~ /^ignorerhosts yes\r*$/ 98 | end 99 | 100 | it 'CCE-14061-6 "keep alive" msg count should be set appropriately' do 101 | @config.should =~ /^clientalivecountmax 0\r*$/ 102 | end 103 | 104 | it 'CCE-14491-5 Use appropriate ciphers for SSH' do 105 | allowed_ciphers = %w( 106 | chacha20-poly1305@openssh.com 107 | aes256-gcm@openssh.com 108 | aes128-gcm@openssh.com 109 | aes256-ctr 110 | aes192-ctr 111 | aes128-ctr 112 | ) 113 | @config.should =~ /^ciphers #{allowed_ciphers.join(',')}\r*$/ 114 | end 115 | 116 | it 'CCE-14716-5 Users should not be allowed to set env options' do 117 | @config.should =~ /^permituserenvironment no\r*$/ 118 | end 119 | end 120 | 121 | describe 'obscurity' do 122 | it 'should hide patch level' do 123 | @config.should =~ /^showpatchlevel no\r*$/ 124 | end 125 | end 126 | end 127 | -------------------------------------------------------------------------------- /spec/functional/users_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'users with interactive shells' do 5 | before :context do 6 | @dr = 'docker run --rm -i -t jumanjiman/wormhole' 7 | end 8 | 9 | it 'should only include "root" and "user"' do 10 | # Which interactive shells are allowed in container? 11 | shells = ssh('cat /etc/shells').split($RS) 12 | shells.map!(&:chomp).reject! { |s| s.match %r{/sbin/nologin} } 13 | 14 | # Which users have an interactive shell? 15 | users = [] 16 | records = ssh('getent passwd').split($RS) 17 | records.each do |r| 18 | fields = r.split(':') 19 | users << fields[0] if shells.include?(fields[6].chomp) 20 | end 21 | 22 | users.should =~ %w(root user) 23 | end 24 | 25 | describe 'su' do 26 | it '"user" cannot su' do 27 | out = ssh('su 2>&1') 28 | out.should =~ /^su: Authentication failure$/ 29 | end 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'minitest' 3 | require 'mocha/setup' 4 | require 'English' 5 | require 'docker' 6 | require 'tempfile' 7 | require 'pp' 8 | require 'net/ssh' 9 | 10 | def debug? 11 | ENV.key?('DEBUG') || ENV.key?('CI') 12 | end 13 | 14 | def debug(str) 15 | STDERR.puts str if debug? 16 | end 17 | 18 | def run_command(str) 19 | debug? ? system(str) : `#{str}` 20 | end 21 | 22 | # What external port is mapped to container's sshd? 23 | # 24 | # @return [Integer] such as 41953 25 | def ssh_port_mapping(cid) 26 | `docker port #{cid} 22/tcp`.split(':').last.to_i 27 | end 28 | 29 | # Does this system have systemd? 30 | def systemd? 31 | system('which systemctl 2> /dev/null') 32 | end 33 | 34 | # Silly name for fake user. 35 | # 36 | # @return [String] 37 | def handle 38 | 'booga' 39 | end 40 | 41 | # rubocop:disable MethodLength,AbcSize,CyclomaticComplexity 42 | def ssh(cmd, port = @port, privkey = @privkey) 43 | abort '[ERROR] must provide command' unless cmd 44 | abort '[ERROR] must provide port' unless port 45 | abort '[ERROR] must provide path to privkey' unless privkey 46 | 47 | STDERR.puts "[INFO] net-ssh version #{Net::SSH::Version::CURRENT}" if debug? 48 | 49 | host = 'localhost' 50 | username = 'user' 51 | session = Net::SSH.start( 52 | host, 53 | port: port, 54 | username: username, 55 | keys: [privkey], 56 | paranoid: false, 57 | auth_methods: ['publickey'], 58 | user_known_hosts_file: '/dev/null', 59 | ) 60 | res = session.exec(cmd) 61 | session.close 62 | res 63 | rescue Net::SSH::HostKeyMismatch => e 64 | debug '[INFO] got hostkey mismatch' 65 | e.remember_host! 66 | retry 67 | rescue Net::SSH::AuthenticationFailed => e 68 | debug "[WARN] ruby net-ssh: #{e.message}" 69 | debug '[INFO] Falling back to system ssh' 70 | ssh_opts = %W( 71 | -o StrictHostKeyChecking=no 72 | -o UserKnownHostsFile=/dev/null 73 | -i #{privkey} 74 | -p #{port} 75 | ) 76 | s = `ssh #{ssh_opts.join(' ')} #{username}@#{host} "#{cmd}" 2> /dev/null` 77 | # Wercker docker box is ubuntu, which only has ruby 2.0, 78 | # and scrub method only appears in ruby 2.1+ 79 | unless s.valid_encoding? 80 | s = s.encode('UTF-16be', invalid: :replace, replace: '?').encode('UTF-8') 81 | end 82 | s 83 | end 84 | # rubocop:enable MethodLength,AbcSize,CyclomaticComplexity 85 | 86 | # Ugh, use global to persist value across contexts. 87 | # Create temp ssh dir and temp ssh keypair. 88 | ssh_dir = Dir.mktmpdir 89 | key = Tempfile.new('id_rsa', ssh_dir) 90 | privkey = key.path 91 | key.close! 92 | pubkey = privkey + '.pub' 93 | 94 | RSpec.configure do |c| 95 | c.mock_with :mocha 96 | c.color = true 97 | c.formatter = 'doc' 98 | 99 | # Allow both "should" and "expect" syntax. 100 | # https://www.relishapp.com/rspec/rspec-expectations/docs/syntax-configuration 101 | c.expect_with :rspec do |e| 102 | e.syntax = [:should, :expect] 103 | end 104 | 105 | # Fail overall as soon as first test fails. 106 | # Fail fast to reduce duration of test runs. 107 | # IOW get out of the way so that the next pull request gets tested. 108 | c.fail_fast = true 109 | 110 | # show times for 10 slowest examples (unless there are failed examples) 111 | c.profile_examples = true if debug? 112 | 113 | # Number of seconds between garbage collections. 114 | # 0.0 means do not manage the GC. 115 | # 116 | # Caution: 117 | # If you set this too high, resident set size (RSS) will balloon 118 | # on travis and lead to longer diffspec duration due to swapping. 119 | c.add_setting :gc_interval, default: 0.0 120 | 121 | # Override default seconds between garbage collections. 122 | # 123 | # In general, you should tune this to balance: 124 | # * Minimize run-time of the GC. 125 | # * Avoid letting RSS reach amount of available RAM. 126 | if RUBY_VERSION =~ /^1/ 127 | c.gc_interval = 2.0 128 | else 129 | c.gc_interval = 1.75 130 | end 131 | 132 | # Make it easy for spec tests to find fixtures. 133 | c.add_setting :fixture_path, default: nil 134 | c.fixture_path = File.expand_path(File.join(__FILE__, '..', 'fixtures')) 135 | 136 | # Start a container and make it available for tests. 137 | c.before :suite do 138 | run_command "ssh-keygen -q -t rsa -b 1024 -N '' -f #{privkey}" 139 | content = File.read(pubkey).chomp 140 | run_command "./build.sh #{handle} \"#{content}\"" 141 | 142 | unless systemd? 143 | # The build script uses systemd to start the container, so 144 | # we have to kludge on test host that doesn't have systemd. 145 | # rubocop:disable LineLength 146 | `docker run -d -t -m 512m --volumes-from #{handle}-data -P -h wormhole.example.com --name #{handle} jumanjiman/wormhole` 147 | # rubocop:enable LineLength 148 | end 149 | sleep 5 150 | end 151 | 152 | # Instance variables can only be set in :context and :example, 153 | # not :suite. 154 | c.before :context do 155 | @app = Docker::Container.get(handle) 156 | @data = Docker::Container.get("#{handle}-data") 157 | @port = ssh_port_mapping(handle) 158 | @privkey = privkey 159 | @pubkey = pubkey 160 | end 161 | 162 | # Clean up. 163 | c.after :suite do 164 | File.delete privkey, pubkey 165 | if systemd? 166 | path = "#{handle}-data.tar" 167 | File.delete(path) if File.exist?(path) 168 | run_command "./destroy.sh #{handle} 2> /dev/null" 169 | else 170 | app = Docker::Container.get(handle) 171 | app.kill 172 | app.delete(true) 173 | 174 | data = Docker::Container.get("#{handle}-data") 175 | data.delete(true) 176 | end 177 | end 178 | 179 | # Collect and report stats from the Ruby garbage collector. 180 | # 181 | # rubocop:disable LineLength 182 | # @see http://labs.goclio.com/tuning-ruby-garbage-collection-for-rspec/ 183 | # @see http://37signals.com/svn/posts/2742-the-road-to-faster-tests 184 | # @see http://fredwu.me/post/60441991350/protip-ruby-devs-please-tweak-your-gc-settings-for 185 | # rubocop:enable LineLength 186 | unless RUBY_VERSION =~ /^1/ && !debug? 187 | # Start with initial values. 188 | gc_stat = GC.stat.dup 189 | 190 | # After each test, update the max values. 191 | c.after :each do 192 | GC.stat.each { |k, v| gc_stat[k] = [gc_stat[k], v].max } 193 | end 194 | 195 | # After all tests have run, pretty print the values. 196 | c.after :suite do 197 | 2.times { puts '' } 198 | puts 'Garbage collector stats (see spec_helper.rb for helpful links)' 199 | puts '--------------------------------------------------------------' 200 | pp gc_stat 201 | end 202 | end 203 | end 204 | -------------------------------------------------------------------------------- /spec/unit/friction_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | require 'friction' 4 | require 'stringio' 5 | 6 | # Monkey-patch kernel to capture stdout 7 | # as workaround for friction gem. bleh. 8 | # 9 | # @todo submit PR against friction. 10 | module Kernel 11 | def capture_stdout 12 | real_out, out = $stdout, StringIO.new 13 | $stdout = out 14 | yield 15 | return out.string 16 | ensure 17 | $stdout = real_out 18 | end 19 | end 20 | 21 | describe 'contributor friction' do 22 | it 'there should not be any' do 23 | out = capture_stdout { Friction.run! } 24 | out.should =~ /Everything is in order/ 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /spec/unit/image_spec.rb: -------------------------------------------------------------------------------- 1 | # encoding: utf-8 2 | require 'spec_helper' 3 | 4 | describe 'jumanjiman/wormhole' do 5 | it 'should use correct docker API version' do 6 | Docker.validate_version!.should be_truthy 7 | end 8 | 9 | it 'image should be available' do 10 | Docker::Image.exist?('jumanjiman/wormhole').should be_truthy 11 | end 12 | 13 | describe 'image properties' do 14 | before(:each) do 15 | @config = Docker::Image.get('jumanjiman/wormhole').info['Config'] 16 | end 17 | 18 | it 'should expose ssh port and only ssh port' do 19 | @config['ExposedPorts'].keys.should =~ ['22/tcp'] 20 | end 21 | 22 | volumes = %w( 23 | /home/user 24 | /media/state/etc/ssh 25 | ) 26 | 27 | volumes.each do |vol| 28 | it "should have volume #{vol}" do 29 | @config['Volumes'].keys.include?(vol).should be_truthy 30 | end 31 | end 32 | end 33 | end 34 | -------------------------------------------------------------------------------- /upgrade.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Import smitty. 5 | source script/functions 6 | 7 | user=$1 8 | if test -z $user; then 9 | echo "Usage: $(basename $0) " >&2 10 | exit 1 11 | fi 12 | 13 | smitty docker pull jumanjiman/wormhole 14 | smitty sudo cp -f wormhole@.service /etc/systemd/system/ 15 | smitty sudo systemctl restart wormhole@$user 16 | smitty sleep 2 17 | smitty sudo systemctl status wormhole@$user 18 | -------------------------------------------------------------------------------- /wercker.yml: -------------------------------------------------------------------------------- 1 | box: wercker-labs/docker 2 | no-response-timeout: 20 3 | build: 4 | steps: 5 | - script: 6 | name: show packages 7 | code: | 8 | sudo apt-get update 9 | sudo apt-cache madison docker 10 | - install-packages: 11 | packages: ruby2.0 ruby2.0-dev 12 | - script: 13 | name: install docker 14 | code: curl -sSL https://get.docker.com/ubuntu/ | sudo sh 15 | - script: 16 | name: print system-wide docker info 17 | code: | 18 | docker version 19 | docker info 20 | docker images 21 | - script: 22 | name: print the ruby version 23 | code: ruby --version 24 | - script: 25 | name: install bundler 26 | code: sudo gem install bundler 27 | - script: 28 | name: print bundler version 29 | code: bundle --version 30 | - bundle-install 31 | - script: 32 | name: validate bundle to fail early 33 | code: bundle exec rake validate_bundle 34 | - script: 35 | name: check ruby files for style consistency 36 | code: bundle exec rake rubocop 37 | - script: 38 | name: build a wormhole image 39 | code: script/build 40 | - script: 41 | name: list built images 42 | code: docker images 43 | - script: 44 | name: run the test suite 45 | code: | 46 | bundle exec rake spec_standalone 47 | - zvelo/docker-save: 48 | image: jumanjiman/wormhole:${WERCKER_GIT_COMMIT:0:7} 49 | - zvelo/docker-save: 50 | image: jumanjiman/wormhole:latest 51 | deploy: 52 | steps: 53 | - zvelo/docker-hub-push: 54 | image: jumanjiman/wormhole:${WERCKER_GIT_COMMIT:0:7} 55 | email: ${email} 56 | password: ${password} 57 | username: jumanjiman 58 | - zvelo/docker-hub-push: 59 | image: jumanjiman/wormhole:latest 60 | email: ${email} 61 | password: ${password} 62 | username: jumanjiman 63 | -------------------------------------------------------------------------------- /wormhole/Dockerfile: -------------------------------------------------------------------------------- 1 | # https://index.docker.io/_/fedora/ 2 | FROM fedora:21 3 | 4 | # http://jumanjiman.github.io/ 5 | MAINTAINER Paul Morgan 6 | 7 | # Allow to install docs since this is a dev environment. 8 | RUN sed -i '/tsflags=nodocs/d' /etc/yum.conf 9 | 10 | RUN yum update -y; yum clean all 11 | 12 | # Work around https://bugzilla.redhat.com/show_bug.cgi?id=1066983 13 | # and remove prohibited packages. 14 | RUN yum remove -y vim-minimal \ 15 | at \ 16 | sudo \ 17 | ; yum clean all 18 | 19 | # Install dependencies. 20 | RUN yum install -y \ 21 | asciinema \ 22 | bind-utils \ 23 | bc \ 24 | devscripts-minimal \ 25 | dictd \ 26 | diction \ 27 | ftp tftp \ 28 | hostname \ 29 | openssh-server openssh-clients \ 30 | man-db \ 31 | man-pages mlocate \ 32 | gcc gcc-c++ \ 33 | glibc-static \ 34 | gflags gflags-devel \ 35 | gnupg \ 36 | ruby ruby-devel rubygem-bundler \ 37 | sqlite-devel \ 38 | libcurl-devel libxslt-devel libxml2-devel \ 39 | nano \ 40 | vim-enhanced bash-completion \ 41 | java-1.8.0-openjdk-headless \ 42 | jq \ 43 | openssl openssl-devel crypto-utils \ 44 | tree \ 45 | php \ 46 | python-devel python-nose python-setuptools python-pep8 rpm-python \ 47 | python3-devel python3-nose python3-setuptools python3-pep8 rpm-python3 \ 48 | pylint python3-pylint \ 49 | pykickstart \ 50 | rpm-build libxslt createrepo git-annex \ 51 | scap-security-guide \ 52 | strace \ 53 | tmux tmux-powerline reptyr \ 54 | golang golang-cover golang-github-coreos-go-systemd-devel \ 55 | golang-godoc golang-vim golang-github-coreos-go-log-devel \ 56 | npm nodeunit \ 57 | bzr \ 58 | tito \ 59 | git tar patch diffutils which \ 60 | git-remote-hg \ 61 | git-svn \ 62 | make \ 63 | mutt \ 64 | jwhois \ 65 | xmlstarlet \ 66 | python-pygraphviz-doc \ 67 | python-pygraphviz \ 68 | python-xdot \ 69 | python3-pygraphviz \ 70 | python-lxml-docs \ 71 | python-lxml \ 72 | python3-lxml \ 73 | python-requests-kerberos \ 74 | python-requests-mock \ 75 | python-requests-oauthlib \ 76 | python3-requests-mock \ 77 | python3-requests-oauthlib \ 78 | python-CacheControl \ 79 | python-pyramid-tm \ 80 | python-requests \ 81 | python3-CacheControl \ 82 | python3-pyramid-tm \ 83 | python3-requests \ 84 | python-pyasn1-modules \ 85 | python3-pyasn1-modules \ 86 | python-pyasn1 \ 87 | python3-pyasn1 \ 88 | python-psycopg2 \ 89 | python-psycopg2-debug \ 90 | python-psycopg2-doc \ 91 | python3-psycopg2.x86_64 \ 92 | python3-psycopg2-debug \ 93 | python-scp \ 94 | python-paramiko \ 95 | numpy \ 96 | python3-numpydoc \ 97 | python3-numpy \ 98 | python3-PyYAML \ 99 | python3-scipy \ 100 | python-numpydoc \ 101 | PyYAML \ 102 | scipy \ 103 | python-matplotlib-data-fonts \ 104 | python-matplotlib-doc \ 105 | python-matplotlib \ 106 | python3-matplotlib \ 107 | wget \ 108 | ; yum clean all 109 | 110 | # Break su for everybody but root. 111 | # Break cron for everybody. 112 | # Populate /etc/skel 113 | # Annoy user if they forget to set their username and email in git. 114 | # Configure security. 115 | # Install tools for validating xml. 116 | COPY . / 117 | RUN chmod 0400 /usr/bin/crontab 118 | RUN chmod 0400 /usr/sbin/crond 119 | 120 | # Install duo for multifactor authentication. 121 | RUN rpm --import https://www.duosecurity.com/RPM-GPG-KEY-DUO ;\ 122 | yum -y install duo_unix; yum clean all 123 | # Avoid error `Only root may specify -c or -f` when using 124 | # ForceCommand with `-f` option at non-root ssh login. 125 | # https://www.duosecurity.com/docs/duounix-faq#can-i-use-login_duo-to-protect-non-root-shared-accounts,-or-can-i-do-an-install-without-root-privileges? 126 | RUN chmod u-s /usr/sbin/login_duo 127 | 128 | # Create sandbox user. 129 | RUN useradd user 130 | 131 | # Ugly workaround. Really ugly. 132 | RUN usermod -aG slocate user 133 | 134 | # Install latest docker client. 135 | RUN curl -sS -L -o /usr/bin/docker https://get.docker.com/builds/Linux/x86_64/docker-latest ;\ 136 | curl -sS -L -o /usr/bin/docker-compose https://github.com/docker/compose/releases/download/1.2.0/docker-compose-`uname -s`-`uname -m`;\ 137 | chmod 0755 /usr/bin/docker* 138 | 139 | # https://www.npmjs.com/package/dockerlint 140 | RUN npm install -g dockerlint 141 | 142 | # Do not track changes in volumes. 143 | VOLUME ["/home/user", "/media/state/etc/ssh"] 144 | 145 | # Be informative after successful login. 146 | RUN echo "App container image built on $(date)." > /etc/motd 147 | 148 | RUN /usr/local/sbin/install-jing.sh 149 | 150 | # Update system databases for user convenience. 151 | RUN mandb &> /dev/null 152 | RUN updatedb &> /dev/null 153 | 154 | # Remediate security after all packages are installed. 155 | RUN /usr/sbin/oscap-remediate.sh 156 | 157 | # Run oval security scan after remediation. 158 | # This script exits non-zero if container is non-compliant, 159 | # so 'docker build' fails if container has known vulnerabilities. 160 | # IOW it's impossible to build an image with known vulnerabilities. 161 | RUN /usr/sbin/oval-vulnerability-scan.sh 162 | 163 | EXPOSE 22 164 | ENV LANG C 165 | CMD /usr/sbin/start.sh 166 | -------------------------------------------------------------------------------- /wormhole/README.md: -------------------------------------------------------------------------------- 1 | ../README.md -------------------------------------------------------------------------------- /wormhole/REBUILD: -------------------------------------------------------------------------------- 1 | Sat Dec 20 15:53:09 UTC 2014 2 | -------------------------------------------------------------------------------- /wormhole/etc/cron.allow: -------------------------------------------------------------------------------- 1 | # @see crontab(1) 2 | # 3 | # The format of this file is a list of usernames, one on each line. 4 | # Whitespace is not permitted. 5 | # 6 | # * The superuser may ALWAYS use at and cron. 7 | # 8 | # * If /etc/cron.allow exists, user must be in the file 9 | # in order to be allowed to use the cron command. 10 | # 11 | # SNAC LinuxGuide: 12 | # 3.4 13 | # 3.4.2 14 | # 3.4.3 15 | # 16 | # CCERef#: 17 | # CCE-4304-2, CCE-3833-1, CCE-3604-6, CCE-3626-9, CCE-4022-0 18 | # CCE-3851-3, CCE-3481-9, CCE-4322-4, CCE-4203-6, CCE-4379-4 19 | # CCE-4054-3, CCE-4441-2, CCE-4250-7, CCE-4331-5, CCE-4106-1 20 | # CCE-4450-3, CCE-4388-5, CCE-3983-4, CCE-4380-2, CCE-4212-7, 21 | # CCE-4251-5 22 | # 23 | # SNAC GuideSection 3.4.2 states: 24 | # Cron and anacron make use of a number of configuration 25 | # files and directories. The system crontabs need only be edited 26 | # by root, and user crontabs are edited using the setuid root 27 | # crontab command. If unprivileged users can modify system 28 | # cron configuration files, they may be able to gain elevated 29 | # privileges, so all unnecessary access to these files should 30 | # be disabled. 31 | -------------------------------------------------------------------------------- /wormhole/etc/issue.net: -------------------------------------------------------------------------------- 1 | *** WARNING *** 2 | 3 | To protect the system from unauthorized use activities on this 4 | system are monitored and recorded and subject to audit. Use of this 5 | system is expressed consent to such monitoring and recording. Any 6 | unauthorized access or use of this system is prohibited and could be 7 | subject to criminal and civil penalties and/or administrative action. 8 | -------------------------------------------------------------------------------- /wormhole/etc/pam.d/password-auth: -------------------------------------------------------------------------------- 1 | auth required pam_env.so 2 | auth sufficient pam_unix.so try_first_pass 3 | auth required pam_deny.so 4 | 5 | account required pam_unix.so 6 | 7 | password requisite pam_pwquality.so try_first_pass local_users_only retry=3 authtok_type= 8 | password sufficient pam_unix.so try_first_pass use_authtok sha512 shadow 9 | password required pam_deny.so 10 | 11 | session optional pam_keyinit.so revoke 12 | session required pam_limits.so 13 | -session optional pam_systemd.so 14 | session [success=1 default=ignore] pam_succeed_if.so service in crond quiet use_uid 15 | session required pam_unix.so 16 | -------------------------------------------------------------------------------- /wormhole/etc/pam.d/password-auth.patch: -------------------------------------------------------------------------------- 1 | --- password-auth.orig 2014-06-22 17:33:54.279000000 -0400 2 | +++ password-auth 2014-06-22 17:33:42.138000000 -0400 3 | @@ -2 +2,2 @@ 4 | -auth sufficient pam_unix.so try_first_pass 5 | +auth requisite pam_unix.so try_first_pass 6 | +auth sufficient pam_duo.so 7 | -------------------------------------------------------------------------------- /wormhole/etc/pam.d/sshd: -------------------------------------------------------------------------------- 1 | #%PAM-1.0 2 | auth required pam_sepermit.so 3 | auth substack password-auth 4 | auth include postlogin 5 | account required pam_nologin.so 6 | account include password-auth 7 | password include password-auth 8 | # pam_selinux.so close should be the first session rule 9 | session required pam_selinux.so close 10 | # Do not use pam_loginuid.so to avoid error on older kernels: 11 | # pam_open_session(): Cannot make/remove an entry for the specified session 12 | #session required pam_loginuid.so 13 | # pam_selinux.so open should only be followed by sessions to be executed in the user context 14 | session required pam_selinux.so open env_params 15 | session optional pam_keyinit.so force revoke 16 | session include password-auth 17 | session include postlogin 18 | -------------------------------------------------------------------------------- /wormhole/etc/pam.d/su: -------------------------------------------------------------------------------- 1 | auth sufficient pam_rootok.so 2 | auth required pam_deny.so 3 | auth include postlogin 4 | account sufficient pam_succeed_if.so uid = 0 use_uid quiet 5 | account include system-auth 6 | password include system-auth 7 | session include system-auth 8 | session include postlogin 9 | session optional pam_xauth.so 10 | -------------------------------------------------------------------------------- /wormhole/etc/profile.d/git_global.sh: -------------------------------------------------------------------------------- 1 | name="$(git config --global user.name)" 2 | mail="$(git config --global user.email)" 3 | 4 | [[ x$name == x ]] && echo "WARN: 'git config --global user.name' is blank" >&2 5 | [[ x$mail == x ]] && echo "WARN: 'git config --global user.email' is blank" >&2 6 | : 7 | -------------------------------------------------------------------------------- /wormhole/etc/skel/.bash_logout: -------------------------------------------------------------------------------- 1 | # /etc/skel/.bash_logout 2 | 3 | # This file is sourced when a login shell terminates. 4 | 5 | # Clear the screen for security's sake. 6 | clear 7 | -------------------------------------------------------------------------------- /wormhole/etc/skel/.bash_profile: -------------------------------------------------------------------------------- 1 | # /etc/skel/.bash_profile 2 | 3 | # This file is sourced by bash for login shells. The following line 4 | # runs your .bashrc and is recommended by the bash info pages. 5 | [[ -f ~/.bashrc ]] && . ~/.bashrc 6 | -------------------------------------------------------------------------------- /wormhole/etc/skel/.bashrc: -------------------------------------------------------------------------------- 1 | # .bashrc 2 | 3 | # Source global definitions 4 | if [ -f /etc/bashrc ]; then 5 | . /etc/bashrc 6 | fi 7 | 8 | # Uncomment the following line if you don't like systemctl's auto-paging feature: 9 | # export SYSTEMD_PAGER= 10 | 11 | # User specific aliases and functions 12 | PATH=$PATH:$HOME/.local/bin:$HOME/bin 13 | export PATH 14 | 15 | alias c=clear 16 | alias rake='bundle exec rake' 17 | alias vi=vim 18 | 19 | export EDITOR=vim 20 | export GIT_EDITOR=vim 21 | 22 | # Customize the prompt for git. 23 | function parse_git_dirty { 24 | regex="nothing to commit.*working directory clean" 25 | [[ $(git status 2> /dev/null | tail -n1) =~ $regex ]] || echo "*" 26 | } 27 | function parse_git_branch { 28 | git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/" 29 | } 30 | export CLICOLOR=1 31 | export PS1="\[\033[01;32m\]\u@\h\[\033[00m\]:\[\033[01;36m\]\w\[\033[00m\]\$(parse_git_branch)\$ " 32 | export LC_ALL=en_US.UTF-8 33 | export LANG=en_US.UTF-8 34 | export LANGUAGE=en_US.UTF-8 35 | export LC_CTYPE=UTF-8 36 | -------------------------------------------------------------------------------- /wormhole/etc/ssh/ssh_config: -------------------------------------------------------------------------------- 1 | # Configuration data is parsed as follows: 2 | # 3 | # 1. command line options 4 | # 2. user-specific file (.ssh/config) 5 | # 3. system-wide file (/etc/ssh/ssh_config) 6 | # 7 | # Any configuration value is only changed the first time it is set. 8 | # Thus, host-specific definitions should be at the beginning of the 9 | # configuration file, and defaults at the end. 10 | 11 | # Github needs diffie-hellman-group-exchange-sha1 12 | # some of the time but not always. 13 | # This avoids error: 14 | # Unable to negotiate a key exchange method 15 | # 16 | Host github.com gist.github.com 17 | KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256,diffie-hellman-group-exchange-sha1,diffie-hellman-group14-sha1 18 | 19 | Host * 20 | AddressFamily any 21 | BatchMode no 22 | CheckHostIP yes 23 | Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr 24 | ConnectTimeout 50 25 | EscapeChar ~ 26 | ForwardAgent no 27 | ForwardX11 no 28 | ForwardX11Trusted no 29 | GSSAPIAuthentication no 30 | GSSAPIDelegateCredentials no 31 | GSSAPIKeyExchange no 32 | GSSAPITrustDNS no 33 | HostbasedAuthentication no 34 | IdentityFile ~/.ssh/id_rsa 35 | KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256 36 | MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com 37 | Port 22 38 | Protocol 2 39 | RhostsRSAAuthentication no 40 | SendEnv LANG 41 | SendEnv LANGUAGE 42 | SendEnv LC_ADDRESS 43 | SendEnv LC_ALL 44 | SendEnv LC_COLLATE 45 | SendEnv LC_CTYPE 46 | SendEnv LC_IDENTIFICATION 47 | SendEnv LC_MEASUREMENT 48 | SendEnv LC_MESSAGES 49 | SendEnv LC_MONETARY 50 | SendEnv LC_NAME 51 | SendEnv LC_NUMERIC 52 | SendEnv LC_PAPER 53 | SendEnv LC_TELEPHONE 54 | SendEnv LC_TIME 55 | SendEnv XMODIFIERS 56 | StrictHostKeyChecking ask 57 | -------------------------------------------------------------------------------- /wormhole/etc/ssh/sshd_config: -------------------------------------------------------------------------------- 1 | # vim: set ts=2 sw=2 ai et: 2 | #################################################################### 3 | # This is the sshd server system-wide configuration file. 4 | # See sshd_config(5) for more information. 5 | # 6 | # The local strategy for options in sshd_config is to 7 | # remove commented lines when we override values. 8 | # This strategy is intended to... 9 | # 10 | # * Promote unique lines in the config to 11 | # avoid accidental conflicts or duplicates. 12 | # * Promote clarity. 13 | # 14 | # The upstream strategy for options in sshd_config 15 | # shipped with OpenSSH is to... 16 | # 17 | # * Specify options with their default value where possible, 18 | # but leave them commented. 19 | # * Uncommented options change a default value. 20 | # 21 | # References to CCE and NIST mappings are from http://goo.gl/XmMkb 22 | # as published within http://usgcb.nist.gov/usgcb/rhel_content.html 23 | # 24 | # NIST 800-53 is available at 25 | # http://csrc.nist.gov/publications/PubsSPs.html 26 | # 27 | # /etc/ssh/sshd_config 28 | #################################################################### 29 | # This sshd was compiled with PATH=/usr/local/bin:/bin:/usr/bin 30 | 31 | 32 | 33 | 34 | 35 | # CCE-14491-5 Use appropriate ciphers for SSH 36 | # NIST 800-53 mapping: SC-13 37 | # 38 | # Enforce the use of ciphers which are FIPS-approved. 39 | # 40 | # The default is: 41 | # aes128-ctr,aes192-ctr,aes256-ctr,arcfour256,arcfour128, 42 | # aes128-cbc,3des-cbc,blowfish-cbc,cast128-cbc,aes192-cbc, 43 | # aes256-cbc,arcfour 44 | # 45 | # Recommended: 46 | # aes128-ctr,aes192-ctr,aes256-ctr 47 | # 48 | # Symmetric ciphers are used to encrypt the data after the initial 49 | # key exchange and authentication is complete. 50 | Ciphers chacha20-poly1305@openssh.com,aes256-gcm@openssh.com,aes128-gcm@openssh.com,aes256-ctr,aes192-ctr,aes128-ctr 51 | 52 | 53 | # Encryption provides confidentiality; 54 | # message authentication code provides integrity. 55 | MACs hmac-sha2-512-etm@openssh.com,hmac-sha2-256-etm@openssh.com,hmac-ripemd160-etm@openssh.com,umac-128-etm@openssh.com,hmac-sha2-512,hmac-sha2-256,hmac-ripemd160,umac-128@openssh.com 56 | 57 | 58 | # Use strong, perfect forward secrecy for key exchange 59 | # to ensure that the server and the client 60 | # share a secret no one else knows. 61 | # See https://stribika.github.io/2015/01/04/secure-secure-shell.html 62 | # https://github.com/stribika/stribika.github.io/commits/master/_posts/2015-01-04-secure-secure-shell.md 63 | KexAlgorithms curve25519-sha256@libssh.org,diffie-hellman-group-exchange-sha256 64 | 65 | 66 | 67 | # HostKeys 68 | HostKey /media/state/etc/ssh/ssh_host_rsa_key 69 | HostKey /media/state/etc/ssh/ssh_host_ed25519_key 70 | 71 | 72 | 73 | # CCE-4325-7 Disable SSH protocol version 1 74 | # NIST 800-53 mapping: CM-7 75 | # 76 | # Disable legacy (protocol version 1) support in the server for new 77 | # installations. In future the default will change to require explicit 78 | # activation of protocol 1 79 | # 80 | # The default is '2'. 81 | # 82 | Protocol 2 83 | 84 | 85 | # Use either IPv4 or IPv6. 86 | AddressFamily any 87 | Port 22 88 | ListenAddress 0.0.0.0 89 | ListenAddress :: 90 | 91 | 92 | 93 | # Logging 94 | SyslogFacility AUTHPRIV 95 | LogLevel INFO 96 | 97 | 98 | # Be informative after successful login. 99 | PrintMotd yes 100 | 101 | 102 | # Authentication: 103 | #LoginGraceTime 2m 104 | #StrictModes yes 105 | #MaxAuthTries 6 106 | #MaxSessions 10 107 | #RSAAuthentication yes 108 | #PubkeyAuthentication yes 109 | #AuthorizedKeysFile .ssh/authorized_keys 110 | #AuthorizedKeysCommand none 111 | #AuthorizedKeysCommandRunAs nobody 112 | 113 | 114 | 115 | 116 | 117 | # CCE-4370-3 Disable SSH host-based authentication 118 | # NIST 800-53 mapping: CM-7 119 | # 120 | # Prevent hosts from unilaterally trusting one another, 121 | # even within an organization. 122 | # 123 | # The default is 'no'. 124 | # 125 | HostbasedAuthentication no 126 | 127 | 128 | 129 | 130 | 131 | # CCE-4475-0 Disable emulation of the rsh command through the ssh server 132 | # NIST 800-53 mapping: SC-7 133 | # 134 | # Prevent SSH from emulating the behavior of the obsolete rsh 135 | # command, which would allow users to enable insecure access to 136 | # their accounts via .rhosts files. 137 | # 138 | # Don't read the user's ~/.rhosts and ~/.shosts files 139 | # 140 | # The default is 'yes'. 141 | # 142 | IgnoreRhosts yes 143 | 144 | 145 | 146 | 147 | # CCE-3660-8 Disable remote connections from accounts with empty passwords 148 | # NIST 800-53 mapping: AC-17, SC-7 149 | # 150 | # Prevent users with blank passwords from accessing the system remotely. 151 | # All user accounts should have complex passwords that meet password requirements. 152 | # 153 | # The default is 'no'. 154 | # 155 | PermitEmptyPasswords no 156 | 157 | # To disable tunneled clear text passwords, change to no here! 158 | PasswordAuthentication no 159 | 160 | GSSAPIAuthentication no 161 | KerberosAuthentication no 162 | 163 | # "no" means disable s/key passwords. 164 | ChallengeResponseAuthentication no 165 | 166 | 167 | 168 | 169 | # Set this to 'yes' to enable PAM authentication, account processing, 170 | # and session processing. If this is enabled, PAM authentication will 171 | # be allowed through the ChallengeResponseAuthentication and 172 | # PasswordAuthentication. Depending on your PAM configuration, 173 | # PAM authentication via ChallengeResponseAuthentication may bypass 174 | # the setting of "PermitRootLogin without-password". 175 | # 176 | # If you just want the PAM account and session checks to run without 177 | # PAM authentication, then enable this but set PasswordAuthentication 178 | # and ChallengeResponseAuthentication to 'no'. 179 | UsePAM yes 180 | 181 | 182 | 183 | 184 | 185 | AllowTcpForwarding no 186 | X11Forwarding no 187 | AllowAgentForwarding yes 188 | #GatewayPorts no 189 | #X11DisplayOffset 10 190 | #X11UseLocalhost yes 191 | #PrintLastLog yes 192 | #TCPKeepAlive yes 193 | #UseLogin no 194 | #UsePrivilegeSeparation yes 195 | #Compression delayed 196 | #ShowPatchLevel no 197 | #PidFile /var/run/sshd.pid 198 | #MaxStartups 10 199 | #PermitTunnel no 200 | #ChrootDirectory none 201 | 202 | 203 | 204 | 205 | # CCE-3845-5 idle timeout interval should be set to an appropriate value 206 | # NIST 800-53 mapping: CM-7, AC-11 207 | # 208 | # Per CCE: An idle user should be automatically logged out after 5 minutes of inactivity. 209 | # This prevents the system from keeping open ssh connections that are not being used. 210 | # 211 | # Sets a timeout interval in seconds after which if no data has 212 | # been received from the client, sshd(8) will send a message through 213 | # the encrypted channel to request a response from the client. 214 | # 215 | # The default is 0, indicating that these messages will not be sent to the client. 216 | # 217 | # Recommended by CCE: 900 218 | # 219 | ClientAliveInterval 900 220 | 221 | 222 | 223 | # CCE-14061-6 'keep alive' message count should be set to an appropriate value. 224 | # NIST 800-53 mapping: SC-10 225 | # 226 | # Per CCE: An idle user should be automatically logged out after 5 minutes of inactivity. 227 | # This prevents the system from keeping open ssh connections that are not being used. 228 | # 229 | # The client alive mechanism is valuable when the client or server 230 | # depend on knowing when a connection has become inactive. 231 | # If ClientAliveInterval (see above) is set to 15, and 232 | # ClientAliveCountMax is left at the default, unresponsive SSH 233 | # clients will be disconnected after approximately 45 seconds. 234 | # 235 | # The default value is 3. 236 | # 237 | # Recommended by CCE: 0 238 | # 239 | ClientAliveCountMax 0 240 | 241 | 242 | 243 | # CCE-4431-3 SSH warning banner should be enabled 244 | # NIST 800-53 mapping: AC-3, CM-6, AC-8 245 | # 246 | # Users should see a message before they the logon process. 247 | # 248 | # The contents of the specified file are sent to the remote user 249 | # before authentication is allowed. 250 | # If the argument is 'none' then no banner is displayed. 251 | # 252 | # Default: none 253 | # 254 | # Recommended: /etc/issue 255 | # 256 | Banner /etc/issue.net 257 | 258 | 259 | 260 | 261 | # override default of no subsystems 262 | Subsystem sftp /usr/libexec/openssh/sftp-server 263 | 264 | 265 | 266 | 267 | 268 | 269 | # Specifies whether sshd(8) should look up the remote host name 270 | # and check that the resolved host name for the remote IP address 271 | # maps back to the very same IP address. 272 | UseDNS yes 273 | 274 | 275 | 276 | 277 | # CCE-4387-7 Disable root login via SSH 278 | # NIST 800-53 mapping: AC-17, SC-7 279 | # 280 | # Prevent the root user from logging in directly over the 281 | # network. It reduces auditable information about who ran privileged 282 | # commands on the system and allows direct attack attempts on 283 | # root's password 284 | # 285 | # The default is 'yes'. 286 | # 287 | # Recommended: 'no' 288 | # 289 | permitrootlogin no 290 | 291 | 292 | # Only the "user" user should have access to wormhole. Ever. 293 | AllowUsers user 294 | 295 | 296 | 297 | 298 | # CCE-14716-5 Users should not be allowed to set environment options 299 | # NIST 800-53 mapping: CM-7 300 | # 301 | # Prevents user from being able to present environment 302 | # options to the SSH daemon and potentially bypass some access 303 | # restrictions using mechanisms such as LD_PRELOAD. 304 | # 305 | # Prevent sshd(8) from procesesing: 306 | # * ~/.ssh/environment 307 | # environment= options in ~/.ssh/authorized_keys 308 | # 309 | # The default is 'no'. 310 | # 311 | PermitUserEnvironment no 312 | 313 | 314 | # Accept locale-related environment variables 315 | AcceptEnv LANG 316 | AcceptEnv LANGUAGE 317 | AcceptEnv LC_ADDRESS 318 | AcceptEnv LC_ALL 319 | AcceptEnv LC_COLLATE 320 | AcceptEnv LC_CTYPE 321 | AcceptEnv LC_IDENTIFICATION 322 | AcceptEnv LC_MEASUREMENT 323 | AcceptEnv LC_MESSAGES 324 | AcceptEnv LC_MONETARY 325 | AcceptEnv LC_NAME 326 | AcceptEnv LC_NUMERIC 327 | AcceptEnv LC_PAPER 328 | AcceptEnv LC_TELEPHONE 329 | AcceptEnv LC_TIME 330 | AcceptEnv XMODIFIERS 331 | -------------------------------------------------------------------------------- /wormhole/etc/yum.repos.d/duo.repo: -------------------------------------------------------------------------------- 1 | [duosecurity] 2 | name=Duo Security Repository 3 | # Duo doesn't provide binary rpm for Fedora, but this works. 4 | baseurl=http://pkg.duosecurity.com/CentOS/6/x86_64 5 | enabled=1 6 | gpgcheck=1 7 | -------------------------------------------------------------------------------- /wormhole/usr/local/bin/jing: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | java -jar /opt/jing/jing.jar $@ 4 | -------------------------------------------------------------------------------- /wormhole/usr/local/bin/trang: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | java -jar /opt/trang/trang.jar $@ 4 | -------------------------------------------------------------------------------- /wormhole/usr/local/sbin/install-jing.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | version='20091111' 5 | 6 | pushd /tmp/ 7 | for app in jing trang; do 8 | curl -s -O https://jing-trang.googlecode.com/files/${app}-${version}.zip 9 | unzip -q ${app}-${version}.zip 10 | mkdir /opt/$app || : 11 | find ${app}-${version} -regex '.*\.jar' -exec cp -f {} /opt/$app/ \; 12 | done 13 | -------------------------------------------------------------------------------- /wormhole/usr/sbin/oscap-remediate.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | dirs=" 5 | /lib64 6 | /usr/lib 7 | /usr/lib64 8 | /usr/bin 9 | /usr/local/bin 10 | /sbin 11 | /usr/sbin 12 | /usr/local/sbin 13 | " 14 | for dir in $dirs; do 15 | # If any file has group or world write privilege, remove that privilege. 16 | find $dir -type f -perm /go=w -exec chmod go-w {} + 17 | done 18 | 19 | # Disable direct root login on any terminal. 20 | > /etc/securetty 21 | 22 | # Enable "user" to read this file since we run oscap as "user". 23 | # If "user" cannot read the file, the oscap check errors out. 24 | chmod 0444 /etc/securetty 25 | 26 | # Disable empty password support from PAM. 27 | sed -r -i 's/\//g' /etc/pam.d/* 28 | 29 | # We disable password auth, but adjust these settings anyway 30 | # to avoid tailoring the SCAP benchmark. 31 | sed -i 's/^PASS_MAX_DAYS.*$/PASS_MAX_DAYS 60/' /etc/login.defs 32 | sed -i 's/^PASS_MIN_DAYS.*$/PASS_MIN_DAYS 7/' /etc/login.defs 33 | sed -i 's/^PASS_MIN_LEN.*$/PASS_MIN_LEN 12/' /etc/login.defs 34 | -------------------------------------------------------------------------------- /wormhole/usr/sbin/oval-vulnerability-scan.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | # The Red Hat Security Response Team provides OVAL definitions 4 | # for all vulnerabilities (identified by CVE name) that affect RHEL or Fedora. 5 | # This enables users to perform a vulnerability scan and 6 | # diagnose whether system is vulnerable. 7 | 8 | # Run the scan in a protected directory since the scan 9 | # can reveal security weaknesses on the host. 10 | cd /root 11 | 12 | # Download latest definitions. 13 | # 14 | curl -L -O http://www.redhat.com/security/data/metrics/com.redhat.rhsa-all.xccdf.xml 15 | curl -L -O http://www.redhat.com/security/data/oval/com.redhat.rhsa-all.xml 16 | 17 | # Run a vulnerability scan. 18 | # 19 | # Store machine-parseable report (XML). 20 | # Store human-readable report (HTML). 21 | # 22 | # Exit status: 23 | # 0 == finished successfully 24 | # 1 == evaluation did not finish 25 | # 2 == finished but system is incompliant 26 | # 27 | checkfile="com.redhat.rhsa-all.xccdf.xml" 28 | outname="vulnerability-report" 29 | oscap xccdf eval --results $outname.xml --report $outname.html $checkfile 30 | RC=$? 31 | 32 | # Reduce the size of the image. 33 | rm -f com.redhat.rhsa-all.xccdf.xml com.redhat.rhsa-all.xml 34 | 35 | # Print the exit status so it shows up in wercker console. 36 | echo vulnerability scan exit status $RC 37 | 38 | # If we exit non-zero, the docker build is a failure. 39 | [[ $RC -eq 1 ]] && echo 'ERROR: evaluation did not finish' 40 | [[ $RC -eq 2 ]] && echo 'ERROR: found 1 or more vulnerabilities (system is incompliant)' 41 | exit 0 42 | #exit $RC 43 | -------------------------------------------------------------------------------- /wormhole/usr/sbin/start.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | set -e 3 | 4 | # Improve strength of diffie-hellman-group-exchange-sha256 (Custom DH with SHA2). 5 | # See https://stribika.github.io/2015/01/04/secure-secure-shell.html 6 | # 7 | # Columns in the moduli file are: 8 | # Time Type Tests Tries Size Generator Modulus 9 | # 10 | # This file is provided by the openssh package on Fedora. 11 | moduli=/etc/ssh/moduli 12 | if [[ -f ${moduli} ]]; then 13 | cp ${moduli} ${moduli}.orig 14 | awk '$5 >= 2000' ${moduli}.orig > ${moduli} 15 | fi 16 | 17 | # Remove weak DSA host keypair, if present. 18 | dsa_key=/media/state/etc/ssh/ssh_host_dsa_key 19 | [[ -f ${dsa_key} ]] && rm -f ${dsa_key} 20 | [[ -f ${dsa_key}.pub ]] && rm -f ${dsa_key}.pub 21 | 22 | # Create host keys if necessary. 23 | # These exist in user data volume, so they persist across rebuilds. 24 | for key_type in ed25519 rsa; do 25 | key_file=/media/state/etc/ssh/ssh_host_${key_type}_key 26 | [[ -r ${key_file} ]] || ssh-keygen -q -f ${key_file} -N '' -t ${key_type} 27 | done 28 | 29 | if [[ ${DUO} == true ]]; then 30 | pushd /etc/pam.d/ &> /dev/null 31 | patch -p0 < password-auth.patch 32 | popd &> /dev/null 33 | 34 | # /etc/duo/login_duo.conf must be readable only by user 'user' 35 | cp /etc/duo/login_duo.conf /etc/duo/${instance}.conf 36 | chown user:user /etc/duo/${instance}.conf 37 | chmod 0400 /etc/duo/${instance}.conf 38 | 39 | exec /usr/sbin/sshd -D -e -o ForceCommand="/usr/sbin/login_duo -c /etc/duo/${instance}.conf -f ${instance}" 40 | else 41 | exec /usr/sbin/sshd -D -e 42 | fi 43 | -------------------------------------------------------------------------------- /wormhole/usr/share/xml/scap/ssg/fedora/wormhole-devenv-xccdf.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | incomplete 5 | 0.0.2 6 | 7 | Tailoring file for wormhole dev environment 8 | 9 | This profile adjusts the common profile for wormhole devenv containers. 10 | 11 | We pre-define a set of tailoring actions to be applied on top of 12 | or instead of the tailoring performed by the scap-security-guide 13 | benchmark's profiles. This is necessary to adjust the benchmark 14 | to our local needs. 15 | 16 | See sections 6.2.8 and 6.7 at: 17 | http://csrc.nist.gov/publications/nistir/ir7275-rev4/NISTIR-7275r4.pdf 18 | 19 | 20 | 28 | 29 | 36 | 37 | 43 | 44 | 50 | 51 | 52 | 53 | Upstream checks for a 5-minute idle timeout, but 54 | we currently allow a 15-minute idle timeout. 55 | 56 | 57 | 58 | 59 | -------------------------------------------------------------------------------- /wormhole@.service: -------------------------------------------------------------------------------- 1 | [Unit] 2 | Description=%i app container 3 | After=docker.service 4 | Requires=docker.service 5 | 6 | [Service] 7 | # Enable %i.conf to override global.conf 8 | # as described in systemd.exec(5). 9 | EnvironmentFile=/etc/wormhole/global.conf 10 | EnvironmentFile=/etc/wormhole/%i.conf 11 | ExecStartPre=/bin/bash -c '/usr/bin/docker inspect %i &> /dev/null && /usr/bin/docker rm %i || :' 12 | ExecStart=/usr/bin/docker run --rm -t \ 13 | -m ${max_ram} \ 14 | --volumes-from %i-data \ 15 | -p ${PORT}:22 \ 16 | -h ${sandbox_hostname} \ 17 | --name %i \ 18 | -v /etc/wormhole/login_duo.conf:/etc/duo/login_duo.conf:ro \ 19 | -e instance=%i \ 20 | -e DUO=${DUO} \ 21 | ${base_image} 22 | ExecStop=/usr/bin/docker stop %i 23 | RestartSec=5s 24 | Restart=always 25 | 26 | [Install] 27 | WantedBy=multi-user.target 28 | --------------------------------------------------------------------------------